Spaces:
Running
Running
Create server.mjs
Browse files- server.mjs +19 -0
server.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import express from 'express';
|
| 2 |
+
import path from 'path';
|
| 3 |
+
import { fileURLToPath } from 'url';
|
| 4 |
+
|
| 5 |
+
const __filename = fileURLToPath(import.meta.url);
|
| 6 |
+
const __dirname = path.dirname(__filename);
|
| 7 |
+
const PORT = process.env.PORT || 7860;
|
| 8 |
+
|
| 9 |
+
const app = express();
|
| 10 |
+
|
| 11 |
+
app.use(express.static(path.join(__dirname, 'dist')));
|
| 12 |
+
|
| 13 |
+
app.get('*', (req, res) => {
|
| 14 |
+
res.sendFile(path.join(__dirname, 'dist', 'index.html'));
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
app.listen(PORT, '0.0.0.0', () => {
|
| 18 |
+
console.log(`Server running on port ${PORT}`);
|
| 19 |
+
});
|