/
app.py
58 lines (52 loc) · 1.82 KB
/
app.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
55
56
57
58
import mConverter
import mDB
import mFind
from flask import Flask, render_template, json, request, redirect, session
from flask.ext.mysql import MySQL
app = Flask(__name__)
app.secret_key = 'why would I tell you my secret key?'
mysql = MySQL()
app.config['MYSQL_DATABASE_USER'] = 'root'
app.config['MYSQL_DATABASE_PASSWORD'] = ''
app.config['MYSQL_DATABASE_DB'] = 'mover'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)
className = ''
term = ''
days = ''
time = ''
myString = ''
myString2 = ''
@app.route("/ShowChooseClass")
def ShowChooseClass():
return render_template('chooseClass.html')
@app.route("/classChooser", methods=['POST'])
def classChooser():
className = request.form['className']
days = request.form['days']
time = request.form['time']
#print className
# setup table 'section'
#term = mDB.setupDB()
term = '201610'#mDB.setupDB()
#_title = request.form['inputTitle'] #make this the course name
# convert the input if user entered anything other than a CRN
if(not className.isdigit()):
className = mConverter.convert(className)
#print className
# use the CRN to setup the tables for student and prereq and find the students in that section
if(className.isdigit()):
myString = mFind.getClassInfo(className, term)
myString2 = mFind.getStudentInfo(className, term, days, time)
# if there is more than one section of a class, and we are unable to convert the
# input into a CRN, we will not build the tables for student and prereqs until we have specifics
print myString2
return json.dumps(str(myString2))
else:
return json.dumps(className)
@app.route("/")
def main():
return render_template('indexMover.html')
if __name__ == "__main__":
app.run(debug = True)
# app.run(host='0.0.0.0')