-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflaskTrain.py
More file actions
36 lines (28 loc) · 869 Bytes
/
flaskTrain.py
File metadata and controls
36 lines (28 loc) · 869 Bytes
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
from flask import Flask, render_template, request, jsonify
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/signin', methods=['POST'])
def signin():
username = request.form['username']
password = request.form['password']
print(username)
print(len(username))
print(password)
print(len(password))
error = None
if len(username) < 5:
error = 'Username must be at least 5 characters'
if len(password) < 6:
error = 'Password must be at least 8 characters'
elif not any(c.isupper() for c in password):
error = 'Your password needs at least 1 capital'
if error is not None:
return jsonify({'r': 1, 'error': error})
return jsonify({'r': 0, 'rs': [username, password]})
@app.route("/home")
def home():
return render_template('home.html')
if __name__ == '__main__':
app.run(debug=True, port=5002)