-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (37 loc) · 1.58 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
from flask import Flask, render_template, request, redirect
app = Flask(__name__)
app.config['DEBUG'] = True
@app.route('/signup', methods=['GET'])
def index():
return render_template('index.html')
@app.route('/signup', methods=['GET', 'POST'])
def validate_form():
username = request.form['username']
username_error = ''
if len(username) < 3 or len(username) > 20:
username_error = "Username must be between 3 and 20 characters"
if ' ' in username:
username_error = "Not a valid username"
password = request.form['password']
password_error = ''
verify = request.form['verify']
verify_error = ''
if len(password) < 3 or len(password) > 20:
password_error = "Password must be between 3 and 20 characters"
password = ''
if ' ' in password:
password_error = "Not a valid password"
password = ''
if verify != password or len(verify) == 0:
verify_error = "Passwords do not match"
verify = ''
email = request.form['email']
email_error = ''
if email != "":
if "@" not in email or "." not in email:
email_error = "Not a valid email."
if not username_error and not password_error and not verify_error and not email_error:
return render_template('welcome.html', username = username)
else:
return render_template('index.html', username = username, username_error = username_error, password_error = password_error, verify_error = verify_error, email = email, email_error = email_error)
app.run()