from flask import Flask, request
app = Flask(__name__)
@app.route('/', methods=['POST'])
def index():
username = request.form['username']
password = request.form['password']
if username == "Jhon" and password == "1":
return f"Welcome {username}"
else:
return f"Welcome!"
if __name__ == '__main__':
app.run(debug=True)
GET and POST
两个文件在同目录下,运行py文件即可。