Moved printer state to API endpoint, made apikey instead of login necessary
This commit is contained in:
1 parent
599bca12a9
commit
6989613b99
1 file changed
+17
-11
+17
-11
@@ -273,17 +273,6 @@ def sdCommand():
|
||||
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
#~~ Printer State
|
||||
|
||||
@app.route(BASEURL + "state", methods=["GET"])
|
||||
@login_required
|
||||
def getPrinterState():
|
||||
currentData = printer.getCurrentData()
|
||||
currentData.update({
|
||||
"temperatures": printer.getCurrentTemperatures()
|
||||
})
|
||||
return jsonify(currentData)
|
||||
|
||||
#~~ GCODE file handling
|
||||
|
||||
@app.route(BASEURL + "gcodefiles", methods=["GET"])
|
||||
@@ -389,6 +378,23 @@ def apiLoad():
|
||||
printer.selectFile(filepath, False, printAfterSelect)
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
@app.route(APIBASEURL + "state", methods=["GET"])
|
||||
def apiPrinterState():
|
||||
if not settings().get(["api", "enabled"]):
|
||||
abort(401)
|
||||
|
||||
if not "apikey" in request.values.keys():
|
||||
abort(401)
|
||||
|
||||
if request.values["apikey"] != settings().get(["api", "key"]):
|
||||
abort(403)
|
||||
|
||||
currentData = printer.getCurrentData()
|
||||
currentData.update({
|
||||
"temperatures": printer.getCurrentTemperatures()
|
||||
})
|
||||
return jsonify(currentData)
|
||||
|
||||
#~~ timelapse handling
|
||||
|
||||
@app.route(BASEURL + "timelapse", methods=["GET"])
|
||||
|
||||
Reference in new issue
Block a user