Flask write with a simple common interface

Testing, the testers will need to write their own interface for system testing, the following interface: The request interface, the interface returns all requested information at the time the request of the interface

 

from flask import Flask, request


app = Flask('test_api')

@app.route('/get_request_info', methods=['post','get'])
def get_request_info():
    resp = {'params_data':'', 'headers':'', 'params_query':'', 'params_form':''}
    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")

Guess you like

Origin www.cnblogs.com/testeyes/p/11445350.html