python实现Flask POST Demo

数据处理逻辑

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


    
Name
Password

两个文件在同目录下,运行py文件即可。

你可能感兴趣的:(python,flask,开发语言)