Skip to content

Instantly share code, notes, and snippets.

@netroy
Created June 26, 2024 11:02
Show Gist options
  • Save netroy/c1933a3ffe636ad2e954b91d5bf02045 to your computer and use it in GitHub Desktop.
Save netroy/c1933a3ffe636ad2e954b91d5bf02045 to your computer and use it in GitHub Desktop.
A static http server that always serves the same latin1 encoded text.
const { createServer } = require('node:http');
const data = Buffer.from(
`El rápido zorro marrón salta sobre el perro perezoso. ¡Qué bello día en París! Árbol, cañón, façade.`,
'latin1',
);
const server = createServer((req, res) => {
res.setHeader('Content-Type', 'text/html; charset=latin1');
res.end(data);
});
server.listen(3000, () => {
console.log('Server is running on http://localhost:3000');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment