Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Nordes
Last active August 30, 2017 02:27
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 Nordes/14c8c0c867d7e3681fe1eabb68a523b1 to your computer and use it in GitHub Desktop.
Save Nordes/14c8c0c867d7e3681fe1eabb68a523b1 to your computer and use it in GitHub Desktop.
NodeJS > create a quick web server and serve files

Init your folder

npm init

Create your index.js

var express = require('express'),
app = express(),
port = process.env.PORT || 8080;

app.use(express.static(__dirname + '/public'));
app.listen(port);

Put all your static file in the ./public folder

mkdir public
mv myFiles ./public

Start your server

node index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment