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

Method _lookup_static_resource

fastapi/routing.py:1935–1948  ·  view source on GitHub ↗
(
        self, path: str
    )

Source from the content-addressed store, hash-verified

1933 raise HTTPException(status_code=404) from None
1934
1935 async def _lookup_static_resource(
1936 self, path: str
1937 ) -> tuple[str, os.stat_result, bool] | None:
1938 full_path, stat_result = await self._lookup_path(path)
1939 if stat_result is None:
1940 return None
1941 if stat.S_ISREG(stat_result.st_mode):
1942 return full_path, stat_result, False
1943 if stat.S_ISDIR(stat_result.st_mode):
1944 index_path = os.path.join(path, "index.html")
1945 full_path, stat_result = await self._lookup_path(index_path)
1946 if stat_result is not None and stat.S_ISREG(stat_result.st_mode):
1947 return full_path, stat_result, True
1948 return None
1949
1950 def _fallback_file_exists(self, fallback: str) -> bool:
1951 _, stat_result = self.lookup_path(fallback)

Callers 1

get_responseMethod · 0.95

Calls 1

_lookup_pathMethod · 0.95

Tested by

no test coverage detected