Spaces:
Runtime error
Runtime error
Download server.ts from tecnosilf/tecenosilf: direct link, hf CLI and curl.
- Browser
- Download file 885 Bytes
-
https://huggingface.co/spaces/tecnosilf/tecenosilf/resolve/main/server.ts
- Command line
-
hf download hf://spaces/tecnosilf/tecenosilf/server.ts
-
curl -L -o server.ts https://huggingface.co/spaces/tecnosilf/tecenosilf/resolve/main/server.ts
885 Bytes
| import express from "express"; | |
| import { createServer as createViteServer } from "vite"; | |
| import path from "path"; | |
| import { fileURLToPath } from "url"; | |
| const __filename = fileURLToPath(import.meta.url); | |
| const __dirname = path.dirname(__filename); | |
| async function startServer() { | |
| const app = express(); | |
| const PORT = Number(process.env.PORT) || 3000; | |
| // Vite middleware for development | |
| if (process.env.NODE_ENV !== "production") { | |
| const vite = await createViteServer({ | |
| server: { middlewareMode: true }, | |
| appType: "spa", | |
| }); | |
| app.use(vite.middlewares); | |
| } else { | |
| app.use(express.static(path.join(__dirname, "dist"))); | |
| app.get("*", (req, res) => { | |
| res.sendFile(path.join(__dirname, "dist", "index.html")); | |
| }); | |
| } | |
| app.listen(PORT, "0.0.0.0", () => { | |
| console.log(`Server running on http://localhost:${PORT}`); | |
| }); | |
| } | |
| startServer(); | |