# -*- coding: utf-8 -*-
# @Time : 2022/10/01
# @Author : chron
# @FileName: hello_world.py
# @Software: PyCharm
# @E-mail : [email protected]
from flask import Flask, request
# 创建flask实例
app = Flask(__name__)
# flask 内建对象
@app.route("/login", methods=["POST", "GET"])
def login():
if request.method == "POST":
if request.form.get("user") == "admin": # 请求的form表单中取参数
return "admin 登录成功"
else:
return "没有这个用户"
else:
if request.args.get("role") == "admin": # 请求的url中取参数
return "admin 登录成功"
else:
return "没有这个用户"
# 启动web服务器 默认运行在5000端口上
# host="0.0.0.0"启用远程调用 port="8888"改变远程端口 debug=True 打开调试模式
if __name__ == '__main__':
app.run(debug=True, host="0.0.0.0", port="8888")
标签:__,return,请求,flask,0.0,request,获取,admin
From: https://www.cnblogs.com/chron/p/16746668.html