#coding:utf-8
import requests
res = requests.post(url="http://192.168.135.105:8888/",data={'normal': '一重国际发展有限公司', 'candidates':"['光大嘉宝股份有限公司', '银川育星达科技股份有限公司', '江苏省水利工程科技咨询股份有限公司']"})
print(res.text)
代码模拟post请求
get请求
from flask import Flask
from original_api_test import post_from_outside
import json
from flask import request
server=Flask(__name__)
@server.route('/',methods=['post','get'])
def get_company_data():
data=request.args.get("DATA")
result=post_from_outside(data)
return result
if __name__ == '__main__':
server.run(host="192.168.137.1",port=8888)
post请求
from flask import request, Flask, jsonify
app = Flask(__name__)
app.config['JSON_AS_ASCII'] = False
@app.route('/test', methods=['POST'])
def post_Data():
print('hh')
postdata = request.form['id']
file = request.files['file']
recognize_info = {'id': postdata, 'info': '收到'+file.filename}
return jsonify(recognize_info), 201
if __name__ == '__main__':
app.run(debug=False, host='0.0.0.0', port=8888)