[Python]Flask獲得post和get參數

from flask import Flask, request
app = Flask(__name__)


@app.route('/')
def test():
    return 'Hello'


@app.route('/hello', methods=['POST', 'GET'])
def hello():
    user = None
    if request.method == 'POST':
        user = request.form.get('user')
    elif request.method == 'GET':
        user = request.args.get('user')
    return 'hi {}'.format(user)

#list all parameters
@app.route('/all_paras', methods=['POST', 'GET'])
def all_paras():
    p = None
    if request.method == 'POST':
        p = request.form.items().__str__()
    elif request.method == 'GET':
        p = request.args.items().__str__()
    return p


if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True, port=8081)