-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
72 lines (57 loc) · 1.93 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
65
66
67
68
69
70
71
72
from flask import Flask, request, redirect, render_template
import cgi
import os
app = Flask(__name__)
app.config['DEBUG'] = True
@app.route("/")
def index():
return render_template('user_form.html')
@app.route('/validate')
def display_user_form():
return render_template('user_form.html')
@app.route("/validate", methods=['POST', 'GET'])
def validate_form():
username = request.form['username']
password = request.form['password']
verify_password = request.form['verify_password']
email = request.form['email']
username_error =''
password_error = ''
v_p_error = ''
email_error = ''
if len(username) < 3 or len(username) > 20:
username_error = "Not a valid username"
username = ''
if password != verify_password:
password_error = "Not a match"
password = ''
else:
password = password
if verify_password != password:
v_p_error = "Not a match, please re-enter password and verification"
password = ''
verify_password = ''
else:
password = password
verify_password = verify_password
if email.count("@") == 1 and email.count(".") == 1 and email.count(" ") == 0:
email = email
else:
email_error="invalid email"
email = ''
if not username_error and not password_error and not v_p_error and not email_error:
return redirect("/Welcome?username={}".format(username))
else:
return render_template('user_form.html',username=username,
username_error=username_error,
password=password,
password_error=password_error,
verify_password=verify_password,
v_p_error=v_p_error,
email=email,
email_error=email_error)
@app.route("/Welcome")
def valid_entry ():
username = request.args.get('username')
return render_template('welcome.html', awesome=username)
app.run()