Skip to content

Instantly share code, notes, and snippets.

Last active November 28, 2019 06:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Vue: Automate Your Routing - index.js (index.html)
const http = require('http');
const fs = require('fs');
let server = http.createServer((req, res) => {
// If the request is for an asset, then send the asset and end the response
if (req.url.includes('assets/')) {
return res.end();
// Tell the client (the browser in our case) we are sending a `text/html` document
res.setHeader('Content-Type', 'text/html');
// Write the contents of our `index.html` file to the response's body
// End the response
return res.end();
// Start at localhost:3000
server.listen(3000, 'localhost', () => {
console.log('Server stared at localhost:3000');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment