static_files.py 522 B

123456789101112131415
  1. from fastapi.staticfiles import StaticFiles
  2. from .. import globals
  3. def add_static_files(path: str, directory: str) -> None:
  4. """Static Files
  5. Makes a local directory available at the specified endpoint, e.g. `'/static'`.
  6. Do only put non-security-critical files in there, as they are accessible to everyone.
  7. :param path: string that starts with a slash "/"
  8. :param directory: folder with static files to serve under the given path
  9. """
  10. globals.app.mount(path, StaticFiles(directory=directory))