salomonsky commited on
Commit
8eba362
·
verified ·
1 Parent(s): 197ca8d

Create server.mjs

Browse files
Files changed (1) hide show
  1. server.mjs +23 -0
server.mjs ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import express from 'express';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ // --- Configuración ---
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+
9
+ // CAMBIO 1: Usar puerto 7860 por defecto (Estándar de Hugging Face)
10
+ const PORT = process.env.PORT || 7860;
11
+
12
+ const app = express();
13
+
14
+ app.use(express.static(path.join(__dirname, 'dist')));
15
+
16
+ app.get('*', (req, res) => {
17
+ res.sendFile(path.join(__dirname, 'dist', 'index.html'));
18
+ });
19
+
20
+ // CAMBIO 2: Escuchar explícitamente en '0.0.0.0'
21
+ app.listen(PORT, '0.0.0.0', () => {
22
+ console.log(`Servidor escuchando en http://0.0.0.0:${PORT}`);
23
+ });