Created
April 18, 2015 03:43
-
-
Save degrammer/daf19158c29d41b4365c to your computer and use it in GitHub Desktop.
Create a local express web server, serve static files inside a folder named public, open a browser in the application port
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
var express = require('express'); | |
var path = require('path'); | |
var express = require('express'); | |
var openPage = require('open'); | |
var packageConfig = require('./package.json'); | |
var server = null; | |
(function(){ | |
console.log("**** Starting express server ******"); | |
this.server = express(); | |
this.server.use('/', express.static(__dirname + '/public')); | |
var applicationPort = packageConfig.port === null ? 80 : packageConfig.port; | |
this.server.listen(applicationPort); | |
console.log("**** Listening at " + applicationPort + " port ****"); | |
openPage("http://localhost:" + applicationPort); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment