-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (25 loc) · 875 Bytes
/
Copy pathserver.js
File metadata and controls
32 lines (25 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// server.js
// Entry point del servicio PREDICT
const express = require("express");
const path = require("path");
const predictRoutes = require("./routes/predictRoutes");
const { initModel } = require("./services/tfModelService");
const PORT = process.env.PORT || 3002;
const app = express();
app.use(express.json());
// Servir la carpeta del modelo TFJS (model/model.json + pesos)
const modelDir = path.resolve(__dirname, "model");
app.use("/model", express.static(modelDir));
// Rutas del servicio PREDICT
app.use("/", predictRoutes);
// Arranque del servidor + carga del modelo
app.listen(PORT, async () => {
const serverUrl = `http://localhost:${PORT}`;
console.log(`[PREDICT] Servicio escuchando en ${serverUrl}`);
try {
await initModel(serverUrl);
} catch (err) {
console.error("Error al inicializar modelo:", err);
process.exit(1);
}
});