module documentation

Add endpoints for static files to the underlying FastAPI server.

Function add_static_file Add a single file to the root of the FastAPI app.
Function add_static_files Add the static files responsible for the webapp app to the FastAPI app.
Function check_static_dir Check that the static dir exists and contains expected files and dirs.
Constant NO_CACHE_HEADERS Undocumented
Constant STATIC_PATH Undocumented
Constant THIS_DIR Undocumented
def add_static_file(app: FastAPI, fname: str, folder: str): (source)

Add a single file to the root of the FastAPI app.

The file with name fname will be mounted at /fname - the folder does not affect where it is mounted in the app.

app: The FastAPI app to add to, in this case the OpenFlexure server fname: the name of the file to add folder: the containing folder of the file

def add_static_files(app: FastAPI, scans_folder: str | None): (source)

Add the static files responsible for the webapp app to the FastAPI app.

Note that any file in the root of the static dir will not be cached. However, the files in mounted subdirectories are not sent with no-cache headers. The Vue CSS and JS are hashed, so if updated their filename will update. The most important file not to cache is "index.html".

Parameters
app:FastAPIThe FastAPI app to add to, in this case the OpenFlexure server
scans_folder:str | NoneThe directory for the scans.
def check_static_dir(): (source)

Check that the static dir exists and contains expected files and dirs.

NO_CACHE_HEADERS: dict[str, str] = (source)

Undocumented

Value
{'Cache-Control': 'no-store, no-cache, must-revalidate, max-age=0',
 'Pragma': 'no-cache',
 'Expires': '0'}
STATIC_PATH = (source)

Undocumented

Value
os.path.normpath(os.path.join(THIS_DIR, '..', 'static'))
THIS_DIR = (source)

Undocumented

Value
os.path.dirname(os.path.abspath(__file__))