Download server.js from CiEL7/miaw: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/CiEL7/miaw/resolve/main/server.js
- Command line
-
hf download hf://spaces/CiEL7/miaw/server.js
-
curl -L -o server.js https://huggingface.co/spaces/CiEL7/miaw/resolve/main/server.js
1.03 kB
| import express from 'express'; | |
| import fetch from 'node-fetch'; | |
| import path from 'path'; | |
| import { fileURLToPath } from 'url'; | |
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | |
| const app = express(); | |
| const PORT = process.env.PORT || 7860; | |
| const FLARESOLVERR_URL = process.env.FLARESOLVERR_URL || 'http://localhost:7860'; | |
| app.use(express.json()); | |
| app.use(express.urlencoded({ extended: true })); | |
| app.use(express.static(__dirname)); | |
| app.post('/proxy', async (req, res) => { | |
| const url = req.body.url; | |
| const payload = { | |
| cmd: 'request.get', | |
| url: url, | |
| }; | |
| try { | |
| const response = await fetch(`${FLARESOLVERR_URL}/v1`, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify(payload) | |
| }); | |
| const data = await response.json(); | |
| res.json(data); | |
| } catch (err) { | |
| console.error(err); | |
| res.status(500).json({ error: 'Request failed' }); | |
| } | |
| }); | |
| app.listen(PORT, () => { | |
| console.log(`Server running on http://localhost:${PORT}`); | |
| }); | |