Created
September 8, 2015 06:25
-
-
Save marbemac/55aaa78f5858484d33f6 to your computer and use it in GitHub Desktop.
Simple node server returning file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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