Download server.js from Lwyeiaons/jp: direct link, hf CLI and curl.
- Browser
- Download file 2 kB
-
https://huggingface.co/spaces/Lwyeiaons/jp/resolve/main/server.js
- Command line
-
hf download hf://spaces/Lwyeiaons/jp/server.js
-
curl -L -o server.js https://huggingface.co/spaces/Lwyeiaons/jp/resolve/main/server.js
2 kB
| const express = require('express'); | |
| const axios = require('axios'); | |
| const app = express(); | |
| const PORT = process.env.PORT || 7860; | |
| app.use(express.json()); | |
| app.use(express.urlencoded({ extended: true })); | |
| app.use(express.static('public')); | |
| // Live Japan Proxy fetch karne ka function | |
| async function getJapanProxy() { | |
| try { | |
| const url = 'https://api.proxyscrape.com/v2/?request=displayproxies&protocol=http&timeout=10000&country=JP&ssl=all&anonymity=all'; | |
| const response = await axios.get(url); | |
| const proxies = response.data.trim().split('\r\n'); | |
| if (proxies.length > 0 && proxies[0] !== "") { | |
| const [host, port] = proxies[0].split(':'); | |
| return { host, port: parseInt(port) }; | |
| } | |
| // Fallback IP agar API fail ho jaye | |
| return { host: '210.140.10.20', port: 8080 }; | |
| } catch (e) { | |
| return { host: '210.140.10.20', port: 8080 }; | |
| } | |
| } | |
| // Yeh route direct website ka data fetch karke screen par render karega | |
| app.get('/go', async (req, res) => { | |
| let targetUrl = req.query.url; | |
| if (!targetUrl) return res.send("URL missing hai!"); | |
| if (!/^https?:\/\//i.test(targetUrl)) { | |
| targetUrl = 'https://' + targetUrl; | |
| } | |
| const proxy = await getJapanProxy(); | |
| console.log(`Using Japan Proxy: ${proxy.host}:${proxy.port}`); | |
| try { | |
| const response = await axios({ | |
| method: 'get', | |
| url: targetUrl, | |
| headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)' }, | |
| proxy: proxy, | |
| timeout: 12000, | |
| responseType: 'text' | |
| }); | |
| // Iframe bypass: Seedhe HTML browser ko bhej do | |
| res.send(response.data); | |
| } catch (error) { | |
| res.status(500).send(`<h3>Proxy Connection Failed</h3><p>Japan Server respond nahi kar raha hai. Dobara try karein. Error: ${error.message}</p>`); | |
| } | |
| }); | |
| app.listen(PORT, '0.0.0.0', () => { | |
| console.log(`Server started on port ${PORT}`); | |
| }); | |