-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathviews.py
More file actions
74 lines (55 loc) · 1.86 KB
/
views.py
File metadata and controls
74 lines (55 loc) · 1.86 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
from flask import Flask, render_template, redirect, request, g, session, url_for, flash
from model import User
import config
import forms
import model
app = Flask(__name__)
app.config.from_object(config)
@app.route("/")
def index():
return render_template("index.html")
# @app.route("/login")
# def login():
# return render_template("login.html")
# @app.route("/login", methods=["POST"])
# def authenticate():
# form = forms.LoginForm(request.form)
# if not form.validate():
# flash("Incorrect username or password")
# return render_template("login.html")
# email = form.email.data
# password = form.password.data
# user = User.query.filter_by(email=email).first()
# if not user or not user.authenticate(password):
# flash("Incorrect username or password")
# return render_template("login.html")
# login_user(user)
# return redirect(request.args.get("next", url_for("index")))
@app.route("/game")
def game():
return render_template("game.html")
@app.route("/about")
def about():
return render_template("about.html")
@app.route("/end")
def end():
return render_template("end.html")
@app.route("/high_scores")
def high_scores():
return render_template("high_scores.html")
@app.route("/high-scores", methods=["POST"])
def post_my_score():
form = forms.LoginForm(request.form)
if not form.validate():
flash("Incorrect username or password")
return render_template("login.html")
email = form.email.data
password = form.password.data
user = User.query.filter_by(email=email).first()
if not user or not user.authenticate(password):
flash("Incorrect username or password")
return render_template("login.html")
login_user(user)
return redirect(request.args.get("next", url_for("index")))
if __name__ == "__main__":
app.run(debug=True)