Skip to content

Instantly share code, notes, and snippets.

@zacck-zz
Created September 2, 2016 10:02
Show Gist options
  • Save zacck-zz/e4298f0028988866fe40529cf9fd87c3 to your computer and use it in GitHub Desktop.
Save zacck-zz/e4298f0028988866fe40529cf9fd87c3 to your computer and use it in GitHub Desktop.
//load module
var express = require('express');
//create our app
var app = express();
const PORT = process.env.PORT || 3000;
//HTTPS TO HTTP
app.use(function (req, res, next){
/*if over http
if(req.headers['x-forwarded-proto'] === 'http') {
res.redirect('https://'+req.hostname +req.url);
} else {
next();
}
*/
});
//show app folder to serve
app.use(express.static('public')); // specifies a a folder name to expose
//start the server
app.listen(PORT, function(){ // takes the port you are serving to and a function
console.log('Express Server is up on port ' + PORT);//log top console
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment