labthings_fastapi.server.fallback ================================= .. py:module:: labthings_fastapi.server.fallback .. autoapi-nested-parse:: A fallback server for LabThings. If the ``fallback`` option is given when ``labthings-server`` is run, we will still start an HTTP server even if we cannot run LabThings with the specified configuration. This means that something will still be viewable at the expected URL, which is helpful if LabThings is running as a service, or on embedded hardware. Attributes ---------- .. autoapisummary:: labthings_fastapi.server.fallback.app labthings_fastapi.server.fallback.ERROR_PAGE Classes ------- .. autoapisummary:: labthings_fastapi.server.fallback.FallbackApp Functions --------- .. autoapisummary:: labthings_fastapi.server.fallback.root labthings_fastapi.server.fallback.redirect_to_root Module Contents --------------- .. py:class:: FallbackApp(*args: Any, **kwargs: Any) Bases: :py:obj:`fastapi.FastAPI` A basic FastAPI application to serve a LabThings error page. Set up a simple error server. This app is used to display a single page, which explains why the LabThings server cannot start. :param \*args: is passed to `fastapi.FastAPI.__init__`\ . :param \**kwargs: is passed to `fastapi.FastAPI.__init__`\ . .. py:attribute:: labthings_config :type: labthings_fastapi.server.config_model.ThingServerConfig | None :value: None .. py:attribute:: labthings_server :type: labthings_fastapi.server.ThingServer | None :value: None .. py:attribute:: labthings_error :type: BaseException | None :value: None .. py:attribute:: log_history :value: None .. py:attribute:: html_code :value: 500 .. py:data:: app .. py:data:: ERROR_PAGE :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """ LabThings

LabThings Couldn't Load

Something went wrong when setting up your LabThings server.

Please check your configuration and try again.

More details may be shown below:

{{error}}

The following Things loaded successfully:

Your configuration:

{{config}}

Traceback

{{traceback}}
{{logginginfo}} """ .. raw:: html
.. py:function:: root() -> fastapi.responses.HTMLResponse :async: Display the LabThings error page. :return: a response that serves the error as an HTML page. .. py:function:: redirect_to_root(path: str) -> starlette.responses.RedirectResponse :async: Redirect all paths on the server to the error page. If any URL other than the error page is requested, this server will redirect it to the error page. :param path: The path requested. :return: a response redirecting to the error page.