javascript - How to setup simple static server where path '/' points to index.html within dirrectory? -


there might simple solution question, not able find answer online , due practice node can't figure out either.

i'm trying set simple server.js file listens on port 80 , serves /dist/index.html file when users enter root address, example.com

this project structure

dist/   index.html   bundle.js node-modules/ package.json server.js 

you can create static server express:

server.js

var express = require('express'); var app = express();  app.use(express.static(__dirname + '/dist'));  app.listen(8080, function() {   console.log('listening on port: ' + 80); }); 

you run node server.js static server. app can deployed.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -