-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
66 lines (56 loc) · 1.85 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
59
60
61
62
63
64
65
66
from flask import Flask, render_template, request
from urllib.parse import unquote
import auth
DEVELOPMENT_ENV = True
app = Flask(__name__)
conn = auth.connect_db(auth.db_config)
auth.create_users_table(conn)
text_content = ""
app_data = {
"name": "medi-sight"
}
@app.route("/")
def index():
return render_template("index.html", app_data=app_data)
@app.route("/login")
def login():
return render_template("login.html", app_data=app_data)
@app.route("/signup")
def signup():
return render_template("signup.html", app_data=app_data)
@app.route("/patient")
def patient():
return render_template("patient.html", app_data=app_data)
@app.route("/doctor")
def doctor():
return render_template("doctor.html", app_data=app_data)
@app.route("/validate", methods=["post"])
def validate():
encoded_username = request.args.get('username')
decoded_username = unquote(encoded_username)
encoded_password = request.args.get('password')
decoded_password = unquote(encoded_password)
is_valid = auth.check_login(conn, decoded_username, decoded_password)
print(decoded_username)
print(decoded_password)
print("valid:",is_valid)
if is_valid:
return {"valid": "success"}
else:
return {"valid": "failure"}
@app.route("/registeruser", methods=["post"])
def registeruser():
encoded_username = request.args.get('username')
decoded_username = unquote(encoded_username)
encoded_password = request.args.get('password')
decoded_password = unquote(encoded_password)
is_valid = auth.check_login(conn, decoded_username, decoded_password)
print(decoded_username)
print(decoded_password)
print("valid:",is_valid)
if is_valid:
return {"valid": "success"}
else:
return {"valid": "failure"}
if __name__ == "__main__":
app.run(debug=DEVELOPMENT_ENV, host='0.0.0.0', port=9000)