Download server.js from Botkaymi/Kay: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/Botkaymi/Kay/resolve/main/server.js
- Command line
-
hf download hf://spaces/Botkaymi/Kay/server.js
-
curl -L -o server.js https://huggingface.co/spaces/Botkaymi/Kay/resolve/main/server.js
1.12 kB
| const http = require('http'); | |
| const { exec } = require('child_process'); | |
| const PORT = 7860; | |
| const RESTART_INTERVAL_MS = 5 * 60 * 60 * 1000; // 5 hours in milliseconds | |
| const startServer = () => { | |
| const server = http.createServer((req, res) => { | |
| res.writeHead(200, { 'Content-Type': 'text/html' }); | |
| res.end('<html><body><b><marquee>KING Alya<marquee></b></body></html>'); | |
| }); | |
| server.listen(PORT, () => { | |
| console.log(`Server listening on port ${PORT}`); | |
| }); | |
| return server; | |
| }; | |
| let server = startServer(); | |
| // Function to restart the server | |
| const restartServer = () => { | |
| console.log('Restarting server...'); | |
| server.close(() => { | |
| console.log('Server stopped.'); | |
| server = startServer(); | |
| }); | |
| }; | |
| // Set up the interval to restart the server every 5 hours | |
| setInterval(restartServer, RESTART_INTERVAL_MS); | |
| // Error handling | |
| process.on('uncaughtException', (err) => { | |
| console.error('Uncaught Exception:', err); | |
| restartServer(); | |
| }); | |
| process.on('unhandledRejection', (reason, promise) => { | |
| console.error('Unhandled Rejection at:', promise, 'reason:', reason); | |
| restartServer(); | |
| }); |