用Flask写一个简单的通用接口
测试工作中,会需要测试人员自己写个接口,用于测试系统,下面的接口实现:请求该接口,接口返回 请求该接口时的所有请求信息
from flask import Flask, request
app = Flask('test_api')@app.route('/get_request_info', methods=['post','get'])
def get_request_info():
resp = dict()
resp['headers'] = dict(request.headers)
resp['params_data'] = dict(request.data)
resp['params_form'] = dict(request.form)
resp['params_query'] = dict(request.args)return resp
if __name__ == '__main__':
app.run(port=8080, debug='true', host="0.0.0.0")