from flask import Flask, request app = Flask(__name__) command = "idle" # 初始指令 @app.route("/set_command", methods=["POST"]) def set_command(): global command command = request.json["command"] return {"status": "success", "command": command} @app.route("/get_command", methods=["GET"]) def get_command(): return {"command": command} if __name__ == "__main__": app.run(host="0.0.0.0", port=5000)