Download server.js from HugVPS/node1: direct link, hf CLI and curl.
- Browser
- Download file 880 Bytes
-
https://huggingface.co/spaces/HugVPS/node1/resolve/main/server.js
- Command line
-
hf download hf://spaces/HugVPS/node1/server.js
-
curl -L -o server.js https://huggingface.co/spaces/HugVPS/node1/resolve/main/server.js
880 Bytes
| const express = require('express'); | |
| const { exec } = require('child_process'); | |
| const path = require('path'); | |
| const app = express(); | |
| const port = 7860; | |
| // Middleware to parse URL-encoded bodies | |
| app.use(express.urlencoded({ extended: true })); | |
| // Serve static files (HTML, CSS, JS) | |
| app.use(express.static(path.join(__dirname, 'public'))); | |
| app.get('/run', (req, res) => { | |
| const command = req.query.command; | |
| if (!command) { | |
| return res.status(400).send('Please provide a command.'); | |
| } | |
| exec(command, (error, stdout, stderr) => { | |
| if (error) { | |
| return res.status(500).send(`Error: ${error.message}`); | |
| } | |
| if (stderr) { | |
| return res.status(500).send(`Output: ${stderr}`); | |
| } | |
| res.send(`${stdout}`); | |
| }); | |
| }); | |
| app.listen(port, () => { | |
| console.log(`Server running at http://localhost:${port}`); | |
| }); |