-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (27 loc) · 766 Bytes
/
app.py
File metadata and controls
33 lines (27 loc) · 766 Bytes
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
from flask import Flask, render_template, redirect, request, abort
from data import get_data, register_data, purge_old_data
app = Flask(__name__)
@app.route("/")
def home():
return redirect("/create")
@app.route("/create")
def create():
return render_template("create.html")
@app.route("/create", methods=["POST"])
def create_post():
data = request.data.decode("UTF8")
data_id = register_data(data)
print(data_id)
return {
"data_id" : data_id
}
@app.route("/result")
def result():
return render_template("result.html")
@app.route("/retrieve/<data_id>")
def retrieve(data_id):
purge_old_data()
data = get_data(data_id)
if data:
return render_template("retrieve.html", data=data)
return abort(404)