-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
64 lines (55 loc) · 2.22 KB
/
main.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
59
60
61
62
63
64
from flask import Flask
from flask import render_template
from flask import request
from flask import redirect
import user_management as dbHandler
# Code snippet for logging a message
# app.logger.critical("message")
app = Flask(__name__)
@app.route("/success.html", methods=["POST", "GET", "PUT", "PATCH", "DELETE"])
def addFeedback():
if request.method == "GET" and request.args.get("url"):
url = request.args.get("url", "")
return redirect(url, code=302)
if request.method == "POST":
feedback = request.form["feedback"]
dbHandler.insertFeedback(feedback)
dbHandler.listFeedback()
return render_template("/success.html", state=True, value="Back")
else:
dbHandler.listFeedback()
return render_template("/success.html", state=True, value="Back")
@app.route("/signup.html", methods=["POST", "GET", "PUT", "PATCH", "DELETE"])
def signup():
if request.method == "GET" and request.args.get("url"):
url = request.args.get("url", "")
return redirect(url, code=302)
if request.method == "POST":
username = request.form["username"]
password = request.form["password"]
DoB = request.form["dob"]
dbHandler.insertUser(username, password, DoB)
return render_template("/index.html")
else:
return render_template("/signup.html")
@app.route("/index.html", methods=["POST", "GET", "PUT", "PATCH", "DELETE"])
@app.route("/", methods=["POST", "GET"])
def home():
if request.method == "GET" and request.args.get("url"):
url = request.args.get("url", "")
return redirect(url, code=302)
if request.method == "POST":
username = request.form["username"]
password = request.form["password"]
isLoggedIn = dbHandler.retrieveUsers(username, password)
if isLoggedIn:
dbHandler.listFeedback()
return render_template("/success.html", value=username, state=isLoggedIn)
else:
return render_template("/index.html")
else:
return render_template("/index.html")
if __name__ == "__main__":
app.config["TEMPLATES_AUTO_RELOAD"] = True
app.config["SEND_FILE_MAX_AGE_DEFAULT"] = 0
app.run(debug=True, host="0.0.0.0", port=5000)