This repository was archived by the owner on Aug 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
71 lines (57 loc) · 1.87 KB
/
views.py
File metadata and controls
71 lines (57 loc) · 1.87 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
from app import app
from flask import Blueprint, render_template,redirect, abort, request, session, flash
from jinja2 import TemplateNotFound
pages = Blueprint('pages', __name__)
# Error message for invaild login
LOGIN_USER_PASS_ERROR = "Username or Password are not mathch to our record"
SIGN_UP_PASSWORD_NOT_MATCH = "The password you enter does not match"
SIGN_UP_USERNAME_TAKEN = "The username you enter has been used"
@pages.route("/")
def start():
return render_template("welcome.html")
@pages.route("/home")
def index():
#show_index()
return render_template("home.html",title = "Index")
@pages.route("/login", methods=['GET', 'POST'])
def login():
page = request.args.get("page",None)
if page is None:
return login_(request)
if page == "signup":
return redirect("/signup")
else:
return redirect("/login")
#should never get to here
abort(404)
@pages.route("/signup", methods = ['GET', 'POST'])
def signup():
error = []
print("signup")
if request.method == 'POST':
if request.form['password'] != request.form['repassword']:
error.append(SIGN_UP_PASSWORD_NOT_MATCH)
error.append(SIGN_UP_USERNAME_TAKEN)
if len(error) == 0:
error = None
return render_template("signup.html",error = error)
@pages.route("/gallery")
def gallery():
return render_template("gallery.html")
@pages.route("/about")
def about():
return render_template("about.html")
@pages.errorhandler(404)
def handle_error(e):
return render_template("error404.html"), 404
def login_(request):
"""
helper function for login
postcondition:
request : request object from the login page
"""
error = None
if request.method == 'POST':
print(request.form['username'])
print(request.form['password'])
return render_template("login.html",error=error)