Created
July 19, 2018 02:21
-
-
Save chellimiller/055513d36bc7bdad95b65cfac98ce7ae to your computer and use it in GitHub Desktop.
Simple development server for a single page app
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 http = require('http'); | |
const url = require('url'); | |
const fs = require('fs'); | |
console.log('Server Started'); | |
http.createServer(function(req, res){ | |
fs.readFile('./index.html', (error, data) => { | |
if (error) { | |
res.writeHead(404, {'Content-type':'text/plain'}); | |
res.write('Page Was Not Found'); | |
} else { | |
res.writeHead(200, {'Content-type':'text/html'}); | |
res.write(data); | |
} | |
res.end(); | |
}) | |
pathName= url.parse(req.url).pathname; | |
console.log(pathName); | |
}).listen(7000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment