Skip to content

Instantly share code, notes, and snippets.

@trajakovic
Last active December 28, 2015 18:39
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 trajakovic/7544569 to your computer and use it in GitHub Desktop.
Save trajakovic/7544569 to your computer and use it in GitHub Desktop.
NodeJs simple static HTTP server. Usage: * Fetch package.json and server.js (same folder) * static content should be placed in public/ folder * run: npm install && npm start
{
"name": "kibana-server",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "3.4.4"
}
}
/**
* Module dependencies.
*/
var express = require('express');
var http = require('http');
var app = express();
// all environments
app.set('port', process.env.PORT || 8000);
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
app.use(function(request, response, next){
//this intercepts all requests
//usefull for logging and stuff
next();
});
app.use(express.static(__dirname+"/public"));
http.createServer(app).listen(app.get('port'), function(){
console.log('Kibana server listening on port ' + app.get('port'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment