Add limits to API calls
This commit is contained in:
@@ -366,6 +366,7 @@ def api_print_image():
|
||||
|
||||
# TODO: This might not depend on the Raspberry Pi
|
||||
@app.route("/api/camera/picture", methods=["GET"])
|
||||
@limiter.limit("6/minute", override_defaults=False)
|
||||
def camera_picture():
|
||||
"""Returns a picture taken by the camera on a raspberry pi"""
|
||||
if RASPBERRY_PI_CONNECTED:
|
||||
@@ -378,24 +379,28 @@ def camera_picture():
|
||||
|
||||
|
||||
@app.route("/api/queue", methods=["GET"])
|
||||
@limiter.limit("6/minute", override_defaults=False)
|
||||
def api_queue_status():
|
||||
"""API endpoint for entire queue"""
|
||||
return jsonify(web.get_queue_state())
|
||||
|
||||
|
||||
@app.route("/api/queue/completed", methods=["GET"])
|
||||
@limiter.limit("6/minute", override_defaults=False)
|
||||
def api_queue_completed():
|
||||
"""API endpoint that returns the finished tasks"""
|
||||
return jsonify(web.get_queue_completed())
|
||||
|
||||
|
||||
@app.route("/api/worker", methods=["GET"])
|
||||
@limiter.limit("6/minute", override_defaults=False)
|
||||
def api_worker_state():
|
||||
"""API endpoint to get the worker state"""
|
||||
return jsonify(worker.current_state())
|
||||
|
||||
|
||||
@app.route("/api/worker/start")
|
||||
@limiter.limit("6/minute", override_defaults=False)
|
||||
def api_worker_start():
|
||||
"""
|
||||
Enable to worker. This starts to process the print queue.
|
||||
@@ -405,6 +410,7 @@ def api_worker_start():
|
||||
|
||||
|
||||
@app.route("/api/worker/stop")
|
||||
@limiter.limit("6/minute", override_defaults=False)
|
||||
def api_worker_stop():
|
||||
"""
|
||||
Stops the print queue. This stops the processing of the print queue.
|
||||
@@ -414,6 +420,7 @@ def api_worker_stop():
|
||||
|
||||
|
||||
@app.route("/api/printers")
|
||||
@limiter.limit("6/minute", override_defaults=False)
|
||||
def api_printers_info():
|
||||
"""Returns the current state of every printers"""
|
||||
return jsonify(printers_pool.printers_info())
|
||||
|
||||
Reference in New Issue
Block a user