MCPcopy Index your code
hub / github.com/fastapi/fastapi / __init__

Method __init__

fastapi/routing.py:1855–1875  ·  view source on GitHub ↗
(
        self,
        *,
        directory: str | os.PathLike[str],
        fallback: Literal["auto", "index.html", "404.html"] | None,
        check_dir: bool = True,
    )

Source from the content-addressed store, hash-verified

1853
1854class _FrontendStaticFiles(StaticFiles):
1855 def __init__(
1856 self,
1857 *,
1858 directory: str | os.PathLike[str],
1859 fallback: Literal["auto", "index.html", "404.html"] | None,
1860 check_dir: bool = True,
1861 ) -> None:
1862 self.fallback = fallback
1863 if check_dir and not os.path.isdir(directory):
1864 raise RuntimeError(
1865 f"Frontend directory '{directory}' does not exist. "
1866 f"Resolved absolute path: '{_get_resolved_absolute_path(directory)}'"
1867 )
1868 super().__init__(
1869 directory=directory,
1870 html=True,
1871 check_dir=check_dir,
1872 follow_symlink=False,
1873 )
1874 if check_dir and fallback in {"index.html", "404.html"}:
1875 self._check_fallback_file(fallback)
1876
1877 def _check_fallback_file(self, fallback: str) -> None:
1878 _, stat_result = self.lookup_path(fallback)

Callers

nothing calls this directly

Calls 3

_check_fallback_fileMethod · 0.95
__init__Method · 0.45

Tested by

no test coverage detected