From 0a47900db45ce82d10ad09a6aee85e1ba68a9063 Mon Sep 17 00:00:00 2001 From: Waref Haque Date: Sun, 17 Jul 2016 18:45:36 -0400 Subject: all files linked to server. Loading the link will load everything --- server.js | 19 ++++++++++--------- 1 file 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) { -- cgit v1.2.3