sda.dashboard.api.app#
FastAPI application factory for the SDA Dashboard backend.
Classes#
StaticFiles variant that falls back to index.html for SPA routes. |
Functions#
|
Create and configure the FastAPI application. |
Module Contents#
- class sda.dashboard.api.app.SPAStaticFiles(*, directory=None, packages=None, html=False, check_dir=True, follow_symlink=False)#
Bases:
fastapi.staticfiles.StaticFilesStaticFiles variant that falls back to index.html for SPA routes.
- async get_response(path, scope)#
Returns an HTTP response, given the incoming path, method and request headers.
- directory = None#
- packages = None#
- all_directories = []#
- html = False#
- config_checked = False#
- follow_symlink = False#
- get_directories(directory=None, packages=None)#
Given directory and packages arguments, return a list of all the directories that should be used for serving static files from.
- get_path(scope)#
Given the ASGI scope, return the path string to serve up, with OS specific path separators, and any ‘..’, ‘.’ components removed.
- lookup_path(path)#
- file_response(full_path, stat_result, scope, status_code=200)#
- async check_config()#
Perform a one-off configuration check that StaticFiles is actually pointed at a directory, so that we can raise loud errors rather than just returning 404 responses.
- is_not_modified(response_headers, request_headers)#
Given the request and response headers, return True if an HTTP “Not Modified” response could be returned instead.
- sda.dashboard.api.app.create_api_app(test_name=None, debug=False, verbose=False, serve_frontend=True)#
Create and configure the FastAPI application.
- Parameters:
test_name – Test(s) to pre-load on startup (forwarded to data manager).
debug – Enable debug/verbose logging.
verbose – Enable verbose pipeline logging.
serve_frontend – If True and
frontend/distexists next to the package root, mount the built React app at/.
- Returns:
Configured FastAPI application instance.
- Return type:
FastAPI