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, cmd):
- args = cmd.split("_")
- c = args[0]
- args.remove(c)
- commands[c] = ", ".join(args)
- return {"Server": "Command updated"}
- class DeleteCommand(Resource):
- def delete(self, cmd):
- commands.pop(cmd, None)
- return {"Server": "Command deleted"}
- api.add_resource(GetCommands, "/getCommands")
- api.add_resource(PostCommand, "/postCommand/<string:cmd>")
- api.add_resource(DeleteCommand, "/deleteCommand/<string:cmd>")
- if __name__ == "__main__":
- app.run(debug=False)
Add Comment
Please, Sign In to add comment