Skip to content

Commit

Permalink
init folder
Browse files Browse the repository at this point in the history
  • Loading branch information
liukai234 committed May 29, 2020
1 parent e26a5ff commit e66669a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions python_web/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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():
# 需要从request对象读取表单内容:
if request.form['username']=='admin' and request.form['password']=='password':
return '<h3>Hello, admin!</h3>'
return '<h3>Bad username or password.</h3>'

if __name__ == '__main__':
app.run(host="0.0.0.0", port=4321)

0 comments on commit e66669a

Please sign in to comment.