"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')
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:
-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 "<h1>Yep, you can do this</h1><small>or this</small>"</code></pre>
-
-<p>
- Take care to set the Content-Type of the request. Supported types below:
-</p>
<h4>Images</h4>
<p>
<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 %}