-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver2.py
More file actions
27 lines (21 loc) · 726 Bytes
/
server2.py
File metadata and controls
27 lines (21 loc) · 726 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
# server2.py
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/', methods = ['GET', 'POST'])
def home():
return '<h1>Home</h1>'
@app.route('/signin', methods = ['GET'])
def signin_form():
return '''<form action = '/signin" method = "post">
<p><input name = "username"></p>
<p><input name = "password" type = "password"></p>
<p><button type = "submit">Sign In</button></p>
</form>'''
@app.route('/signin', methods = ['POST'])
def signin():
if request.form['username'] == 'admin' and request.form['password'] == 'password':
return '<h3>Hello, admin!</h3>'
return '<h3>Bad username of password.</h3>'
if __name__ == '__main__':
app.run()