1 主程序app.py
from flask import Flask,request
app = Flask(__name__)
@app.route("/ranking/<babyId>/<albumId>")
def ranking(babyId,albumId):
return "BabyId is :%s \n AlbumId is :%s" % (babyId,albumId)
@app.route("/tryPost",methods=["POST"])
def tryPost():
babyId = request.form['babyId']
albumId = request.form['albumId']
return "BabyId is :%s \n AlbumId is :%s" % (babyId,albumId)
2 运行flask
vim run.sh
export FLASK_APP=app.py
flask run --host=0.0.0.0
3 post 请求
import requests
post_data = {
"babyId":"19865292",
"albumId":"1975233"
}
res = requests.post(url="http://0.0.0.0:5000/tryPost",data=post_data)
print (res.text)
网友评论