aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaref Haque <warefhaque@inside-239-60.wireless.utoronto.ca>2016-07-17 22:45:36 +0000
committerWaref Haque <warefhaque@inside-239-60.wireless.utoronto.ca>2016-07-17 22:45:36 +0000
commit0a47900db45ce82d10ad09a6aee85e1ba68a9063 (patch)
tree7d60669a8a8aee7b8239b2db2fd0a34d269db061
parente58943c3e620f05937656fdde032254ae3373f36 (diff)
all files linked to server. Loading the link will load everything
-rw-r--r--server.js19
1 files changed, 10 insertions, 9 deletions
diff --git a/server.js b/server.js
index e3eae24..c937cd0 100644
--- a/server.js
+++ b/server.js
@@ -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) {