服务端
# -*- coding: utf-8 -*- from flask import Flask,request flask_app = Flask(‘55kai‘) @flask_app.route(‘/lubenwei‘,methods=[‘POST‘]) def go(**kwargs): name = request.values.get(‘name‘) return ("hello,{}".format(name)) if __name__ == ‘__main__‘: flask_app.run(host=‘127.0.0.1‘, port=int(‘2627‘), use_reloader=True)
客户端
# -*- coding=utf-8 -*- import requests data = {‘name‘: ‘faker‘, ‘age‘: 25} r = requests.post(‘http://127.0.0.1:2627/lubenwei‘,data=data) print(r.content)
原文:https://www.cnblogs.com/gyc-tzx/p/14994461.html