Spaces:
Sleeping
Sleeping
Download proxy.js from ClaraSu/ollama-server: direct link, hf CLI and curl.
- Browser
- Download file 560 Bytes
-
https://huggingface.co/spaces/ClaraSu/ollama-server/resolve/main/proxy.js
- Command line
-
hf download hf://spaces/ClaraSu/ollama-server/proxy.js
-
curl -L -o proxy.js https://huggingface.co/spaces/ClaraSu/ollama-server/resolve/main/proxy.js
560 Bytes
| const http = require('http') | |
| http.createServer((req,res) => { | |
| const options = { | |
| hostname: 'localhost', | |
| port: 11434, | |
| path: req.url, | |
| method: req.method, | |
| headers: req.headers | |
| } | |
| const proxy = http.request(options, (proxyRes) => { | |
| res.writeHead(proxyRes.statusCode, proxyRes.headers) | |
| proxyRes.pipe(res) | |
| }) | |
| proxy.on('error', (err) => { | |
| err.writeHead(502) | |
| err.end("Ollama not ready: " + err.message) | |
| }) | |
| req.pipe(proxy) | |
| }).listen(7860, '0.0.0.0', () => { | |
| console.log('Port proxy running: 7860 -> 11434') | |
| }) |