Skip to content

Instantly share code, notes, and snippets.

@siliskin
siliskin / server.js
Created July 13, 2012 22:38 — forked from alaingilbert/server.js
EventSource server with nodejs
var http = require('http')
, fs = require('fs')
, PORT = process.argv[2] || 8080
, HOST = process.argv[3] || '127.0.0.1';
http.createServer(function (req, res) {
if (req.url == '/events') {
res.writeHead(200, { 'Content-Type' : 'text/event-stream'
, 'Cache-Control' : 'no-cache'