# -*- 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__)
# http请求方法
@app.route("/login", methods=["POST", "PUT", "GET"])
def login():
# 在特定请求处理中调用request,会映射到对应路由的请求上
# 区分大小写
if request.method == "POST":
return "这是一个post请求"
elif request.method == "PUT":
return "这是一个put请求"
elif request.method == "GET":
return "这是一个get请求"
# 启动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")
标签:__,http,请求,flask,0.0,app,request
From: https://www.cnblogs.com/chron/p/16746663.html