forked from maxjdobrei/cuHacking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
54 lines (41 loc) · 1.79 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from flask import Flask, render_template, request, session
from cuSchedulingParser import superMain
session = {}
session['scheduleIndex'] = 0
session['schedules'] = [[]]
schedules = [[]]
app = Flask(__name__)
@app.route("/main", methods=['GET','POST'])
def hello():
days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
courses = []
schedules = [[]]
if request.method == 'POST':
if request.form['form'] == 'generate':
term = request.form['term']
myBreak = request.form['break']
if myBreak != "":
addT = 0
if(myBreak[-2:-1] == "PM"):
addT = 12
myBreak = str(int(myBreak[:2])+addT)+":"+myBreak[3:5]
timePreference = request.form['time-preference']
if timePreference == "No Preference":
timePreference = ""
for i in range(1,7,1):
if request.form['course'+str(i)] != "":
courses.append(request.form['course'+str(i)])
session['schedules'] = superMain(term,courses,myBreak,timePreference)
#schedules = superMain(term,courses,myBreak,timePreference)
session['scheduleIndex'] = 0
if request.form['form'] == 'previous':
session['scheduleIndex'] -= 1
if session['scheduleIndex'] < 0:
session['scheduleIndex'] = len(session['schedules'])-1
if request.form['form'] == 'next':
session['scheduleIndex'] += 1
if session['scheduleIndex'] > len(session['schedules'])-1:
session['scheduleIndex'] = 0
return render_template("main.html",days = days, schedule = session['schedules'][session['scheduleIndex']])
if __name__ == '__main__':
app.run(debug=True)