-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
93 lines (77 loc) · 3 KB
/
app.py
File metadata and controls
93 lines (77 loc) · 3 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from flask import Flask, jsonify, render_template, request
from flask import render_template
from flask import jsonify
from flask import request
import User
import courseProcessing as cp
import pandas as pd
import os
import json
# Added a static folder where we can upload pictures
image_folder = os.path.join('static', 'image_folder')
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = image_folder
newUser = User.User()
@app.route('/')
def home():
# Allows me to display the logo onto the home page
full_filename = os.path.join(app.config['UPLOAD_FOLDER'], 'logo.jpg')
return render_template('home.html', logo = full_filename)
@app.route('/course_dir/')
def course_dir():
courses = cp.getAllCourses().values
full_filename = '/static/image_folder/logo.jpg'
return render_template('course_dir.html', courses = courses, logo = full_filename)
@app.route('/roadmap/')
def roadmap():
courses = cp.getAllCourses().values
full_filename = '/static/image_folder/logo.jpg'
return render_template('roadmap.html', courses = courses, logo = full_filename)
# Test method for requesting data
@app.route('/_add_numbers')
def add_numbers():
a = request.args.get('a', 0, type=int)
b = request.args.get('b', 0, type=int)
return jsonify(result=a * b)
@app.route('/_getAllCurrentCourses')
def getCurrentCourses():
'''Returns json of all the courses'''
currentCoursesJSON = json.dumps(newUser.getCurrentCourses())
dictCourses = newUser.getCurrentCourses()
indicies = [int(v) for v in dictCourses.values()]
currentCourses = cp.getAllCourses().iloc[indicies].to_json(orient='index')
return jsonify(result=currentCourses)
@app.route('/_addCourseById')
def addCourseById():
'''Looks at request and adds the course ID to a list'''
# print(request.args.to_dict())
courseCode = request.args.to_dict()
course = courseCode['courseRowID']
newUser.addCourse(course)
return 'None'
@app.route('/_update_course_list')
def updateCourseList():
'''Looks at request and adds the course ID to a list'''
queryParamsDict = request.args.to_dict()
filtGenGradReq = queryParamsDict['filtGenGradReq']
filtMonday = queryParamsDict['M']
filtTuesday = queryParamsDict['T']
filtWednesday = queryParamsDict['W']
filtThursday = queryParamsDict['R']
filtFriday = queryParamsDict['F']
# Build the query list
queryList = []
for i, v in queryParamsDict.items():
if v == 'true':
queryList.append(i)
updatedCourses = cp.filterCourses(queryList).to_json(orient='index')
return jsonify(result=updatedCourses)
# Link to documentation page
@app.route('/documentation')
def documentation():
full_filename = os.path.join(app.config['UPLOAD_FOLDER'], 'Untitled.png')
full_filename_mvp = os.path.join(app.config['UPLOAD_FOLDER'], 'mvpPlan.png')
print(full_filename, full_filename_mvp)
return render_template('Documentation2.html', diagram = full_filename, mvp = full_filename_mvp)
if __name__ == '__main__':
app.run(debug=True)