2noy

开关灯测试 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)

分类:

技术点:

相关文章: