How to use the octoprint.plugin.BlueprintPlugin.route function in OctoPrint

To help you get started, weโ€™ve selected a few OctoPrint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vitormhenrique / OctoPrint-Enclosure / octoprint_enclosure / __init__.py View on Github external
    @octoprint.plugin.BlueprintPlugin.route("/outputs", methods=["GET"])
    def get_outputs(self):
        outputs = []
        for rpi_output in self.rpi_outputs:
            if rpi_output['output_type'] == 'regular':
                index = self.to_int(rpi_output['index_id'])
                label = rpi_output['label']
                outputs.append(dict(index_id=index, label=label))
        return Response(json.dumps(outputs), mimetype='application/json')
github tohara / OctoPrint-BigBoxFirmware / octoprint_bigboxfirmware / __init__.py View on Github external
    @octoprint.plugin.BlueprintPlugin.route("/firmwareprofiles/", methods=["DELETE"])
    @octoprint.server.util.flask.restricted_access
    @octoprint.server.admin_permission.require(403)
    def deleteProfile(self, identifier):
        dataFolder = self.get_plugin_data_folder()
        file_path = dataFolder + '/profiles/' + identifier
           
        if os.path.isfile(file_path):
            os.remove(file_path)
                 
        return flask.make_response("", 204)
github tohara / OctoPrint-BigBoxFirmware / octoprint_bigboxfirmware / __init__.py View on Github external
    @octoprint.plugin.BlueprintPlugin.route("/firmwareprofiles", methods=["GET"])
    def getProfileList(self):
        dataFolder = self.get_plugin_data_folder()
        profile_folder = dataFolder + '/profiles'
        
        if not os.path.isdir(profile_folder):
            os.mkdir(profile_folder)
        
        _,_,fileList = os.walk(profile_folder).next()
        
        returnDict = {}
        
        for pFile in fileList:
            with open(profile_folder +'/'+ pFile, 'r+b') as f:
                profile = eval(f.read())['profile']
                returnDict[profile['id']] = profile
github vitormhenrique / OctoPrint-Enclosure / octoprint_enclosure / __init__.py View on Github external
    @octoprint.plugin.BlueprintPlugin.route("/neopixel/", methods=["PATCH"])
    @restricted_access
    def set_neopixel(self, identifier):
        """ set_neopixel method get request from octoprint and send the command to arduino or neopixel"""
        if "application/json" not in request.headers["Content-Type"]:
            return make_response("expected json", 400)
        try:
            data = request.json
        except BadRequest:
            return make_response("malformed request", 400)

        if 'red' not in data:
            return make_response("missing red attribute", 406)
        if 'green' not in data:
            return make_response("missing green attribute", 406)
        if 'blue' not in data:
            return make_response("missing blue attribute", 406)
github AstroPrint / OctoPrint-AstroPrint / octoprint_astroprint / __init__.py View on Github external
	@octoprint.plugin.BlueprintPlugin.route("/astrobox/identify", methods=["GET"])
	def identify(self):
		if not self.astroprintCloud or not self.astroprintCloud.bm:
			abort(503)
		return Response(json.dumps({
			'id': self.astroprintCloud.bm.boxId,
			'name': self._settings.get(["boxName"]),
			'version': self._plugin_version,
			'firstRun': True if self._settings.global_get_boolean(["server", "firstRun"]) else None,
			'online': True,
		})
github tohara / OctoPrint-BigBoxFirmware / octoprint_bigboxfirmware / __init__.py View on Github external
    @octoprint.plugin.BlueprintPlugin.route("/firmwareprofiles/", methods=["PATCH"])
    @octoprint.server.util.flask.restricted_access
    @octoprint.server.admin_permission.require(403)
    def updateProfile(self, identifier):
        dataFolder = self.get_plugin_data_folder()
        profile_folder = dataFolder + '/profiles'
        
        if not os.path.isdir(profile_folder):
            os.mkdir(profile_folder)
            
        profile_id = flask.request.json['profile']['id']
        
        profile_file = open(profile_folder + '/' + profile_id, 'w+b')
        
        profile_file.write(str(flask.request.json))
        profile_file.flush()
        profile_file.close()
github OllisGit / OctoPrint-PrintJobHistory / octoprint_PrintJobHistory / api / PrintJobHistoryAPI.py View on Github external
	@octoprint.plugin.BlueprintPlugin.route("/deleteDatabase", methods=["DELETE"])
	def delete_database(self):

		self._databaseManager.recreateDatabase()

		return flask.jsonify({
			"result": "success"
		})
github AstroPrint / OctoPrint-AstroPrint / octoprint_astroprint / __init__.py View on Github external
	@octoprint.plugin.BlueprintPlugin.route("/changefilament", methods=["DELETE"])
	@admin_permission.require(403)
	def removefilament(self):
		self._settings.set(['filament'], {'name' : None, 'color' : None})
		self._settings.save()
		self.astroprintCloud.bm.triggerEvent('filamentChanged', {'filament' : {'name' : None, 'color' : None}})
		return jsonify({"Filament removed" : True }), 200, {'ContentType':'application/json'}
github michaelnew / Octoprint-Print-Queue / octoprint_print_queue / __init__.py View on Github external
    @octoprint.plugin.BlueprintPlugin.route("/addselectedfile", methods=["GET"])
    def addSelectedFile(self):
        self._logger.info("PQ: adding selected file: " + self.selected_file)
        self._printer.unselect_file()
        f = self.selected_file
        self.selected_file = ""
        return flask.jsonify(filename=f)
github AstroPrint / OctoPrint-AstroPrint / octoprint_astroprint / __init__.py View on Github external
	@octoprint.plugin.BlueprintPlugin.route("/canceldownload", methods=["POST"])
	@admin_permission.require(403)
	def canceldownload(self):
		id = request.json['id']
		self.astroprintCloud.downloadmanager.cancelDownload(id)
		return jsonify({"success" : True }), 200, {'ContentType':'application/json'}