Skip to content

Instantly share code, notes, and snippets.

@marbemac
Created September 8, 2015 06:25
Show Gist options
  • Save marbemac/55aaa78f5858484d33f6 to your computer and use it in GitHub Desktop.
Save marbemac/55aaa78f5858484d33f6 to your computer and use it in GitHub Desktop.
Simple node server returning file
// Load the http module to create an http server.
var http = require('http');
var largeResponse = require('./large_response.json')
largeResponse = JSON.stringify(largeResponse)
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "application/json"});
// response.end('{"hello": "world"}');
response.end(largeResponse);
});
// Listen on port 3000, IP defaults to 127.0.0.1
server.listen(3000);
// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:3000/");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment