Skip to content

Instantly share code, notes, and snippets.

@Srushtika
Created November 16, 2018 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Srushtika/e35b89e23c84c52628fb0e6122f1ea49 to your computer and use it in GitHub Desktop.
Save Srushtika/e35b89e23c84c52628fb0e6122f1ea49 to your computer and use it in GitHub Desktop.
WebSockets server tutorial
const http = require('http');
const static = require('node-static');
const file = new static.Server('./');
const server = http.createServer((req, res) => {
req.addListener('end', () => file.serve(req, res)).resume();
});
const port = 3210;
server.listen(port, () => console.log(`Server running at http://localhost:${port}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment