From e58943c3e620f05937656fdde032254ae3373f36 Mon Sep 17 00:00:00 2001 From: Waref Haque Date: Sun, 17 Jul 2016 16:24:49 -0400 Subject: redirect commit --- server.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 server.js (limited to 'server.js') diff --git a/server.js b/server.js new file mode 100644 index 0000000..e3eae24 --- /dev/null +++ b/server.js @@ -0,0 +1,45 @@ +/** + * Created by warefhaque on 2016-07-16. + */ + +const express = require('express'); +const app = express(); +const bodyParser = require('body-parser'); +var dbFile = require("./node_simple.js"); +var http = require("http"); +var fs = require("fs"); + +app.use(bodyParser.urlencoded({extended: true})); +app.use(bodyParser.json()); +app.use(express.static('public')); + +app.listen(3000, function() { + console.log('listening on 3000'); +}); + + + +app.get('/exams',function (req,res) { + console.log(req.query.search); + var courseName = req.query.search; + res.redirect("http://localhost:3000/exams.html/?course_name="+courseName); +}); + +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'); +}); + +function getExamsForCourseCode(courseCode) { + dbFile.get_all_exams(courseCode, function (exams) { + if (exams.length == 0){ + console.log("Nothing was found"); + } + else { + console.log(exams); + } + }); +} -- cgit v1.2.3