from flask import Flask, request, Response
import json
from flask_cors import *
app = Flask(__name__)
CORS(app, supports_credentials=True)
@app.route('/sfs', methods=['POST'])
def t1():
data = request.data
# 你的处理逻辑函数
resp = Response()
resp.data = data # 处理结果数据
resp = "OK---------------------------------------"
return resp
@app.route('/kfc', methods=['GET'])
def t2():
data = request.args.to_dict()
# 你的处理逻辑函数
resp = Response()
resp.data = data # 处理结果数据
resp = "OK---------------------------------------"
return resp
if __name__ == '__main__':
app.run('0.0.0.0', port=6600)
访问
import requests, json
## 调用 加法 服务
url_local = 'http://172.23.209.45:6600/abc'
h1 = requests.post(url=url_local, data=json.dumps({"a": 1, "b": 2}))
print(h1.text)