Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask
- from flask_restful import Api, Resource
- app = Flask(__name__)
- api = Api(app)
- commands = {}
- class GetCommands(Resource):
- def get(self):
- return commands
- class PostCommand(Resource):
- def post(self, command):
- args = command.split("_")
- cmd = args[0]
- args.remove(cmd)
- commands[cmd] = ", ".join(args)
- return {"data": "Updated commands"}
- api.add_resource(GetCommands, "/getCommands")
- api.add_resource(PostCommand, "/postCommand/<string:command>")
- if __name__ == "__main__":
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement