-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflask_helloworld.py
More file actions
33 lines (26 loc) · 1.14 KB
/
flask_helloworld.py
File metadata and controls
33 lines (26 loc) · 1.14 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
from flask import Flask, request
from markupsafe import escape
def create_app(config):
app = Flask(__name__)
app.config.from_object(config)
@app.route("/", methods=['GET'])
def hello_world():
return "<p>Hello, World!</p>"
@app.route("/", methods=['POST'])
def hello_world_post():
return f"{escape(request.form['username'])} with {escape(request.form['password'])}"
@app.route("/user/<name>")
def hello_someone(name):
return f"Hello, {escape(name)}!"
@app.route("/login/", methods=['POST'])
def login_verification_post():
username = escape(request.form['username'])
password = escape(request.form['password'])
if (username == 'toto' and password == 'toto95'):
return f"Hello {username}!"
if (username == 'admin' and password == 'adminpw'):
return f"Hello {username}! You are the admin acoount."
if (username == 'admin' and password == 'adminpw2145') or (username == 'toto' and password == 'toto8256') :
return f"Username and password do not match. Try again"
return app
app = create_app({"TESTING": False})