diff options
| author | Waref Haque <warefhaque@inside-239-60.wireless.utoronto.ca> | 2016-07-17 22:45:36 +0000 |
|---|---|---|
| committer | Waref Haque <warefhaque@inside-239-60.wireless.utoronto.ca> | 2016-07-17 22:45:36 +0000 |
| commit | 0a47900db45ce82d10ad09a6aee85e1ba68a9063 (patch) | |
| tree | 7d60669a8a8aee7b8239b2db2fd0a34d269db061 | |
| parent | e58943c3e620f05937656fdde032254ae3373f36 (diff) | |
all files linked to server. Loading the link will load everything
| -rw-r--r-- | server.js | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -2,6 +2,10 @@ * Created by warefhaque on 2016-07-16. */ +/*change the __dirname statically for now*/ + +var __dirname = '/Users/warefhaque/CSC309/solutions_repo'; + const express = require('express'); const app = express(); const bodyParser = require('body-parser'); @@ -11,14 +15,13 @@ var fs = require("fs"); app.use(bodyParser.urlencoded({extended: true})); app.use(bodyParser.json()); -app.use(express.static('public')); +/*LOADS ALL STATIC FILES FROM THE DIRECTORY __dirname*/ +app.use(express.static(__dirname)); app.listen(3000, function() { - console.log('listening on 3000'); + console.log('listening on http://localhost:3000/'); }); - - app.get('/exams',function (req,res) { console.log(req.query.search); var courseName = req.query.search; @@ -26,11 +29,9 @@ app.get('/exams',function (req,res) { }); app.get('/exams.html', function (req,res) { - res.sendFile('/Users/warefhaque/CSC309/solutions_repo/exams.html'); -}); - -app.get("/exams.html/assets/css/style.css",function (req,res) { - res.sendFile('/Users/warefhaque/CSC309/solutions_repo/assets/css/style.css'); + /*LOADS ALL THE STATIC FILES REALTIVE TO THE REDIRECTED URL*/ + app.use('/exams.html', express.static(__dirname)); + res.sendFile(__dirname+'/exams.html'); }); function getExamsForCourseCode(courseCode) { |
