pyra.webapp#

Responsible for serving the webapp.

pyra.webapp.api_settings(configuration_spec: str | None) Response[source]#

Get current settings or save changes to settings from web ui.

This endpoint accepts a GET or POST request. A GET request will return the current settings. A POST request will process the data passed in and return the results of processing.

Parameters:
configuration_specOptional[str]

The spec to return. In the future this will be used to return config specs of plugins; however that is not currently implemented.

Returns:
Response

A response formatted as flask.jsonify.

Examples

>>> callback_dashboard()
<Response ... bytes [200 OK]>
pyra.webapp.callback_dashboard() Response[source]#

Get dashboard data.

This should be used in a callback in order to update charts in the web app.

Returns:
Response

A response formatted as flask.jsonify.

See also

pyra.hardware.chart_data

This function sets up the data in the proper format.

Examples

>>> callback_dashboard()
<Response ... bytes [200 OK]>
pyra.webapp.docs(filename) send_from_directory[source]#

Serve the Sphinx html documentation.

Todo

This documentation needs to be improved.

Parameters:
filenamestr

The html filename to return.

Returns:
flask.send_from_directory

The requested documentation page.

Notes

The following routes trigger this function.

/docs/ /docs/<page.html>

Examples

>>> docs(filename='index.html')
pyra.webapp.favicon() send_from_directory[source]#

Serve the favicon.ico file.

Todo

This documentation needs to be improved.

Returns:
flask.send_from_directory

The ico file.

Notes

The following routes trigger this function.

/favicon.ico

Examples

>>> favicon()
pyra.webapp.home() render_template[source]#

Serve the webapp home page.

Todo

This documentation needs to be improved.

Returns:
render_template

The rendered page.

Notes

The following routes trigger this function.

/ /home

Examples

>>> home()
pyra.webapp.render_template(template_name_or_list, **context)[source]#

Render a template, while providing our default context.

This function is a wrapper around flask.render_template. Our UI config is added to the template context. In the future, this function may be used to add other default contexts to templates.

Parameters:
template_name_or_liststr

The name of the template to render.

**context

The context to pass to the template.

Returns:
render_template

The rendered template.

Examples

>>> render_template(template_name_or_list='home.html', title=_('Home'))
pyra.webapp.settings(configuration_spec: str | None) render_template[source]#

Serve the configuration page page.

Todo

This documentation needs to be improved.

Parameters:
configuration_specOptional[str]

The spec to return. In the future this will be used to return config specs of plugins; however that is not currently implemented.

Returns:
render_template

The rendered page.

Notes

The following routes trigger this function.

/settings

Examples

>>> settings()
pyra.webapp.start_webapp()[source]#

Start the webapp.

Start the flask webapp. This is placed in it’s own function to allow the ability to start the webapp within a thread in a simple way.

Examples

>>> start_webapp()
 * Serving Flask app 'pyra.webapp' (lazy loading)
...
 * Running on http://.../ (Press CTRL+C to quit)
>>> from pyra import webapp, threads
>>> threads.run_in_thread(target=webapp.start_webapp, name='Flask', daemon=True).start()
 * Serving Flask app 'pyra.webapp' (lazy loading)
...
 * Running on http://.../ (Press CTRL+C to quit)
pyra.webapp.status() dict[source]#

Check the status of RetroArcher.

This is useful for a healthcheck from Docker, and may have many other uses in the future for third party applications.

Returns:
dict

A dictionary of the status.

Examples

>>> status()
pyra.webapp.test_logger() str[source]#

Test logging functions.

Check ./logs/pyra.webapp.log for output.

Returns:
str

A message telling the user to check the logs.

Notes

The following routes trigger this function.

/test_logger

Examples

>>> test_logger()