From: Joe Rickerby Date: Thu, 11 Jan 2018 13:26:17 +0000 (+0000) Subject: Add documentation for print status API X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=77ede6a7e5cac74921906994546fd6cb6b84a329;p=sirius.git Add documentation for print status API --- diff --git a/sirius/web/print_key_api.py b/sirius/web/print_key_api.py index 1f59010..4b8ddcb 100644 --- a/sirius/web/print_key_api.py +++ b/sirius/web/print_key_api.py @@ -39,7 +39,6 @@ def print_with_print_key(print_key_secret): "status": 'online' if printer.is_online else 'offline' } - print request.accept_mimetypes html_preference_score = request.accept_mimetypes.quality('text/html') json_preference_score = request.accept_mimetypes.quality('application/json') @@ -47,7 +46,7 @@ def print_with_print_key(print_key_secret): return flask.render_template( 'print_key.html', printer=printer, - printer_info=printer_info, + printer_info_json=json.dumps(printer_info, indent=2), print_key=print_key, ) else: diff --git a/sirius/web/templates/print_key.html b/sirius/web/templates/print_key.html index 970e32c..9f09615 100644 --- a/sirius/web/templates/print_key.html +++ b/sirius/web/templates/print_key.html @@ -63,6 +63,12 @@ -H 'content-type: text/plain' \ -d 'boop beep boop' + + +

+ Take care to set the Content-Type of the request. Supported types below: +

+

HTML

Content-Type: text/html @@ -71,10 +77,6 @@

curl '{{request.url}}?from=htmlexample' \
     -H 'content-type: text/html' \
     -d "<h1>Yep, you can do this</h1><small>or this</small>"
- -

- Take care to set the Content-Type of the request. Supported types below: -

Images

@@ -83,7 +85,7 @@ Content-Type: image/jpeg

Prints out the image data from the request body, in a lovely dithered style.

-
cat mindblown.gif | curl {{request.url}}?from=image-example \
+
cat mindblown.gif | curl '{{request.url}}?from=image-example' \
     -X POST \
     -H 'content-type: image/gif' \
     --data-binary @-
@@ -96,6 +98,21 @@
curl '{{request.url}}?from=text-example' \
     -H 'content-type: text/plain' \
     -d "I'm a little teapot"
+ + + +

Status API

+ +

This URL is also a status API e.g.

+ +
curl '{{request.url}}'
+ +

This returns the status of the printer in JSON format.

+ +

e.g.

+ +
{{printer_info_json}}
+ {% endblock %} {% block scripts %}