Spaces:
Runtime error
Runtime error
Download node_modules/eventsource/example/sse-server.js from MarkoVidrih/Language-Vision-Model: direct link, hf CLI and curl.
- Browser
- Download file 672 Bytes
-
https://huggingface.co/spaces/MarkoVidrih/Language-Vision-Model/resolve/main/node_modules/eventsource/example/sse-server.js
- Command line
-
hf download hf://spaces/MarkoVidrih/Language-Vision-Model/node_modules/eventsource/example/sse-server.js
-
curl -L -o sse-server.js https://huggingface.co/spaces/MarkoVidrih/Language-Vision-Model/resolve/main/node_modules/eventsource/example/sse-server.js
672 Bytes
| const express = require('express') | |
| const serveStatic = require('serve-static') | |
| const SseStream = require('ssestream') | |
| const app = express() | |
| app.use(serveStatic(__dirname)) | |
| app.get('/sse', (req, res) => { | |
| console.log('new connection') | |
| const sseStream = new SseStream(req) | |
| sseStream.pipe(res) | |
| const pusher = setInterval(() => { | |
| sseStream.write({ | |
| event: 'server-time', | |
| data: new Date().toTimeString() | |
| }) | |
| }, 1000) | |
| res.on('close', () => { | |
| console.log('lost connection') | |
| clearInterval(pusher) | |
| sseStream.unpipe(res) | |
| }) | |
| }) | |
| app.listen(8080, (err) => { | |
| if (err) throw err | |
| console.log('server ready on http://localhost:8080') | |
| }) | |