-
Notifications
You must be signed in to change notification settings - Fork 11
/
webapp.py
35 lines (26 loc) · 902 Bytes
/
webapp.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
from flask import Flask, render_template, request
from sort import sort_routes
from moonboard import Display
import json
import ast
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/problem/", methods=["POST", "GET"])
def problem():
if request.method == "GET":
return "bruh"
if request.method == "POST":
grade = request.form["Grade"]
sort = request.form["sort"]
problem_list = sort_routes(grade, sort)
return render_template("problem.html", problem_list=problem_list)
@app.route("/setproblem/", methods=["POST"])
def setproblem():
# hold function here
problem_json = json.loads(json.dumps(ast.literal_eval(request.form['problem'])))
display.displayProblem(problem_json)
return render_template("problem.html")
display = Display()
app.run()