Skip to content

Instantly share code, notes, and snippets.

@alfredwesterveld
Created July 27, 2016 20:10
Show Gist options
  • Select an option

  • Save alfredwesterveld/d18d8b1d7834f4417410297d638f27b8 to your computer and use it in GitHub Desktop.

Select an option

Save alfredwesterveld/d18d8b1d7834f4417410297d638f27b8 to your computer and use it in GitHub Desktop.
fake longpoll server
'use strict';
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
let i = 0;
const server = http.createServer((req, res) => {
setTimeout(() => {
console.log(i++);
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
}, 1000);
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
{
"name": "fake-longpoll",
"version": "0.0.1",
"description": "fake longpoll server",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment