import requests
import json
url = "http://192.168.10.153:5000/modeltest/hello"
url2 = "http://192.168.10.153:5000/modeltest/bye"
req = {"key":"value"}
req2 = {"data":"Hi."}
req3 = {"data":"BYE."}
ret = requests.get(url, params=req2)
print(ret.text)
ret = requests.get(url2, params=req3)
print(ret.text)
ret=requests.post(url, data=json.dumps(req))
print(ret.text)
ret=requests.post(url, data=json.dumps(req2))
print(ret.text)
ret=requests.post(url2, data=json.dumps(req))
print(ret.text)
ret=requests.post(url2, data=json.dumps(req3))
print(ret.text)
使用flask request解析GET、POST请求
from flask import request
import json
if request.method == "POST":
data = request.get_data()
data_d = json.loads(data)
elif request.method == "GET":
data_d = request.args.to_dict()
网友评论