Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
CGWebServer/index.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
22 lines (17 sloc)
527 Bytes
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
//import express module | |
var express = require('express'); | |
//create an express app | |
var app = express(); | |
//this comment was added on 8th Jan 2020 | |
const path = require('path'); | |
app.use(express.static('public')); | |
//add a callback function to handle | |
//get request on the root | |
app.get('/', function(req, res) { | |
res.sendFile(path.join(__dirname+'/html/index.html')); | |
}); | |
app.get('/about', function(req, res) { | |
res.sendFile(path.join(__dirname+'/html/about.html')); | |
}); | |
//run the server on port 3000 | |
app.listen(3000); |