Spaces:
Sleeping
Sleeping
Download index.js from KiritoAxinity/Sakuga: direct link, hf CLI and curl.
- Browser
- Download file 934 Bytes
-
https://huggingface.co/spaces/KiritoAxinity/Sakuga/resolve/main/index.js
- Command line
-
hf download hf://spaces/KiritoAxinity/Sakuga/index.js
-
curl -L -o index.js https://huggingface.co/spaces/KiritoAxinity/Sakuga/resolve/main/index.js
934 Bytes
| var express = require('express') | |
| const path = require('path') | |
| const { createProxyMiddleware } = require('http-proxy-middleware') | |
| var app = express() | |
| let port = process.env.PORT; | |
| if (port == null || port == "") { | |
| port = 8000; | |
| } | |
| app.use('/api', createProxyMiddleware({ | |
| target: 'https://www.sakugabooru.com', | |
| changeOrigin: true, | |
| pathRewrite: {'^/api' : ''}, | |
| onProxyReq: (proxyReq, req, res) => { | |
| // Force the headers to look like a real browser | |
| proxyReq.setHeader('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'); | |
| proxyReq.setHeader('Referer', 'https://www.sakugabooru.com/'); | |
| proxyReq.setHeader('Origin', 'https://www.sakugabooru.com'); | |
| } | |
| })); | |
| app.use('/', express.static(path.join(__dirname, 'public'))) | |
| app.listen(port, '0.0.0.0', () => { | |
| console.log(`Server is running on port ${port}`); | |
| }); |