Skip to content

Instantly share code, notes, and snippets.

@robertcoopercode
Created November 12, 2017 19:36
Show Gist options
  • Save robertcoopercode/f9186cbffaa68eb46345ae9b5aa7d11e to your computer and use it in GitHub Desktop.
Save robertcoopercode/f9186cbffaa68eb46345ae9b5aa7d11e to your computer and use it in GitHub Desktop.
// Require express and create an express application instance
const express = require('express');
const app = express();
// Require the express routes defined in router.js
const routes = require('./router');
// Define the hostname and port where the server can be found
const hostname = "127.0.0.1";
const port = 3000;
// Define the directory where static files are found
app.use(express.static('public'));
// Specify the routes to be used for our application
app.use(routes);
// Begin accepting connections to the specified port
app.listen(port, () => {
// Display server location information to the console
console.log(`Server is listening at http://${hostname}:${port}/`);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment