-
-
Save xgenvn/942f0fd5edf3dc77b250e95bae1adf4e to your computer and use it in GitHub Desktop.
NodeJS server for a single-page app with client navigation and no backend.
This file contains hidden or 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
| 'use strict'; | |
| var http = require( "http" ), | |
| pathUtils = require( "path" ), | |
| express = require( "express" ), | |
| app = express(), | |
| PORT = process.env.PORT || 5000, | |
| appDir = pathUtils.resolve( __dirname, "client" ); | |
| app.use( express.static( appDir ) ); | |
| app.get( "*", function( req, res ) { | |
| res.sendfile( pathUtils.resolve( appDir, "index.html" ) ); | |
| } ); | |
| http.createServer( app ).listen( PORT, function() { | |
| console.log( "Express server listening on port " + PORT ); | |
| console.log( "http://localhost:" + PORT ); | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment