labthings_fastapi.server
Submodules
Package Contents
Classes
Functions
Create a ThingServer from a configuration dictionary |
API
- class labthings_fastapi.server.ThingServer(settings_folder: Optional[str] = None)
Initialization
- app: fastapi.FastAPI
None
- action_manager: labthings_fastapi.actions.ActionManager
None
- blob_data_manager: labthings_fastapi.outputs.blob.BlobDataManager
None
- property things: collections.abc.Mapping[str, labthings_fastapi.thing.Thing]
Return a dictionary of all the things
- ThingInstance
‘TypeVar(…)’
- things_by_class(cls: type[ThingInstance]) Sequence[ThingInstance]
Return all Things attached to this server matching a class
- thing_by_class(cls: type[ThingInstance]) ThingInstance
The Thing attached to this server matching a given class.
A RuntimeError will be raised if there is not exactly one matching Thing.
- add_thing(thing: labthings_fastapi.thing.Thing, path: str)
Add a thing to the server
- async lifespan(app: fastapi.FastAPI)
Manage set up and tear down
This does two important things:
It sets up the blocking portal so background threads can run async code (important for events)
It runs setup/teardown code for Things.
- add_things_view_to_app()
Add an endpoint that shows the list of attached things.
- labthings_fastapi.server.server_from_config(config: dict) labthings_fastapi.server.ThingServer
Create a ThingServer from a configuration dictionary