Created
July 20, 2016 10:06
-
-
Save jubalm/82bb7a76a82e7c1effa906a372160887 to your computer and use it in GitHub Desktop.
Simple express server
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
const path = require('path'); | |
const express = require('express'); | |
const port = process.env.PORT || 3000; | |
const server = express(); | |
server.get('/favicon.ico', function(req, res) { | |
res.writeHead(200, { 'Content-Type': 'image/x-icon' }); | |
res.end(); | |
}); | |
server.use(express.static(path.resolve(__dirname, 'public'))); | |
server.listen(port, (err) => { | |
if (err) { | |
console.error(err); | |
} | |
console.info(`🌎 Listening on port ${port}. Open up http://localhost:${port}/ in your browser.`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment