]> git.aero2k.de Git - sirius.git/commitdiff
Add documentation for print status API
authorJoe Rickerby <joerick@mac.com>
Thu, 11 Jan 2018 13:26:17 +0000 (13:26 +0000)
committerJoe Rickerby <joerick@mac.com>
Thu, 11 Jan 2018 13:26:17 +0000 (13:26 +0000)
sirius/web/print_key_api.py
sirius/web/templates/print_key.html

index 1f59010ed335a307add92ee1d9f7313cdd9cc3f4..4b8ddcbcf2124e2ad23d383fe684c2f841425131 100644 (file)
@@ -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:
index 970e32c627247237edc25a853de9b9d4fdb75a39..9f09615a90b484741c7527de873da3a95ea633d5 100644 (file)
     -H 'content-type: text/plain' \
     -d 'boop beep boop'</code></pre>
 
+
+<div class="hidden-xs" style="height: 1em"></div>
+<p>
+    Take care to set the Content-Type of the request. Supported types below:
+</p>
+
 <h4>HTML</h4>
 <p>
     <code>Content-Type: text/html</code>
 <pre><code>curl '{{request.url}}?from=htmlexample' \
     -H 'content-type: text/html' \
     -d "&lt;h1&gt;Yep, you can do this&lt;/h1&gt;&lt;small&gt;or this&lt;/small&gt;"</code></pre>
-    
-<p>
-    Take care to set the Content-Type of the request. Supported types below:
-</p>
 
 <h4>Images</h4>
 <p>
@@ -83,7 +85,7 @@
     <code>Content-Type: image/jpeg</code>
 </p>
 <p>Prints out the image data from the request body, in a lovely dithered style.</p>
-<pre><code>cat mindblown.gif | curl {{request.url}}?from=image-example \
+<pre><code>cat mindblown.gif | curl '{{request.url}}?from=image-example' \
     -X POST \
     -H 'content-type: image/gif' \
     --data-binary @-</code></pre>
 <pre><code>curl '{{request.url}}?from=text-example' \
     -H 'content-type: text/plain' \
     -d "I'm a little teapot"</code></pre>
+
+<div class="hidden-xs" style="height: 1em"></div>
+
+<h4>Status API</h4>
+
+<p>This URL is also a status API e.g.</p>
+
+<pre><code>curl '{{request.url}}'</code></pre>
+
+<p>This returns the status of the printer in JSON format.</p>
+
+<p>e.g.</p>
+
+<pre><code>{{printer_info_json}}</code></pre>
+
 {% endblock %}
 
 {% block scripts %}