使用 postman入门接口测试 - get请求

开关灯测试 get请求

参考:https://www.cnblogs.com/yyhh/p/6083159.html
postman官方文档:https://learning.getpostman.com/

使用 postman测试 get请求

开关灯测试.png

后端 python小程序

# light.py
from flask import Flask, request

app = Flask(__name__)

@app.route('/light')
def light():
    res = 'hello, world'
    print(request.args)
    if request.args.get('opt') == 'close':
        res = '关灯了'
    elif request.args.get('opt') == 'open':
        res = '开灯了'
    return res

if __name__ == '__main__':
    app.run(debug=True)
posted @ 2019-07-15 09:43  杨择文  阅读(576)  评论(0)    收藏  举报