Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import octoprint.plugin
- import flask
- class MySimpleApiPlugin(octoprint.plugin.SimpleApiPlugin):
- def get_api_commands(self):
- return dict(
- command1=[],
- command2=["some_parameter"],
- command3=[],
- command4=[]
- )
- def on_api_command(self, command, data):
- import flask
- if command == "command1":
- parameter = "unset"
- if "parameter" in data:
- parameter = "set"
- self._logger.info("command1 called, parameter is {parameter}".format(**locals()))
- elif command == "command2":
- self._logger.info("command2 called, some_parameter is {some_parameter}".format(**data))
- elif command == "command3":
- print "test"
- return flask.jsonify(foo="bar")
- elif command == "command4":
- return make_response("testantwort", 200)
- def on_api_get(self, request):
- return flask.jsonify(foo="bar")
- #return make_response("testantwort", 200)
- __plugin_implementation__ = MySimpleApiPlugin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement