Spaces:
Sleeping
Sleeping
Create server.js
Browse files
server.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// server.js
|
| 2 |
+
import express from "express";
|
| 3 |
+
import path from "path";
|
| 4 |
+
import { fileURLToPath } from "url";
|
| 5 |
+
|
| 6 |
+
const __filename = fileURLToPath(import.meta.url);
|
| 7 |
+
const __dirname = path.dirname(__filename);
|
| 8 |
+
|
| 9 |
+
const app = express();
|
| 10 |
+
const PORT = process.env.PORT || 7860;
|
| 11 |
+
|
| 12 |
+
// Serve static files from /public
|
| 13 |
+
app.use(express.static(path.join(__dirname, "public"), { extensions: ["html"] }));
|
| 14 |
+
|
| 15 |
+
// Default route (serve index.html)
|
| 16 |
+
app.get("/", (req, res) => {
|
| 17 |
+
res.sendFile(path.join(__dirname, "public", "index.html"));
|
| 18 |
+
});
|
| 19 |
+
|
| 20 |
+
app.listen(PORT, "0.0.0.0", () => {
|
| 21 |
+
console.log(`✅ Server running at http://localhost:${PORT}`);
|
| 22 |
+
});
|