Spaces:
Sleeping
Sleeping
Download server.js from moustafa7/protofolio: direct link, hf CLI and curl.
- Browser
- Download file 733 Bytes
-
https://huggingface.co/spaces/moustafa7/protofolio/resolve/main/server.js
- Command line
-
hf download hf://spaces/moustafa7/protofolio/server.js
-
curl -L -o server.js https://huggingface.co/spaces/moustafa7/protofolio/resolve/main/server.js
733 Bytes
| const express = require("express"); | |
| const { createProxyMiddleware } = require("http-proxy-middleware"); | |
| const path = require("path"); | |
| const app = express(); | |
| const PORT = process.env.PORT || 7860; | |
| // Proxy API to backend | |
| app.use( | |
| "/api", | |
| createProxyMiddleware({ | |
| target: "http://localhost:5000", | |
| changeOrigin: true, | |
| pathRewrite: { "^/": "/api/" }, | |
| }) | |
| ); | |
| // Serve uploads | |
| app.use("/uploads", express.static(path.join(__dirname, "backend", "uploads"))); | |
| // Serve frontend | |
| app.use(express.static(path.join(__dirname, "public"))); | |
| // SPA fallback | |
| app.use((req, res) => { | |
| res.sendFile(path.join(__dirname, "public", "index.html")); | |
| }); | |
| app.listen(PORT, () => { | |
| console.log(`Server running on port ${PORT}`); | |
| }); | |