#Server memory ?
4 messages · Page 1 of 1 (latest)
I'd like to replicate the behaviour of this nodejs script, but inside Astro:
const http = require('http');
let count = 0;
setInterval(() => {
count++;
}, 1000);
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.write(`<h1>Count: ${count}</h1>`);
res.end();
});
server.listen(4321, () => {
console.log('Server running at http://localhost:4321/');
});
This increments a variable, every second, and I can see this variable update if I refresh my page
I should specify that I am currently configured with NodeJS server rendering using the Standalone mode. Is it possible or would I be required to use the middleware mode ?
I was able to get a working solution by installing and using ExpressJs. Can I do without ?