Created
May 29, 2015 07:26
-
-
Save DannyDelott/c91eb480e1c8d08fd928 to your computer and use it in GitHub Desktop.
Simple node server
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
/* ***************** | |
* Require Imports * | |
* *****************/ | |
var express = require('express'); | |
var path = require('path'); | |
/* *********************** | |
* Initialize Middleware * | |
* **********************/ | |
// Instantiate the express object | |
var app = express(); | |
// Use the static assets from the same directory as this server.js file | |
app.use(express.static(path.resolve("./"))); | |
/* ************** | |
* GET Requests * | |
* **************/ | |
// index.html | |
app.get('/', function(req, res) { | |
res.sendFile('index.html'); | |
}); | |
/* ****************** | |
* Start the server * | |
* ******************/ | |
var port = process.env.PORT || 8000; | |
var server = app.listen(port, function() { | |
console.log('Listening on port:', port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment