MCPcopy
hub / github.com/encode/starlette / check_config

Method check_config

starlette/staticfiles.py:189–203  ·  view source on GitHub ↗

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.

(self)

Source from the content-addressed store, hash-verified

187 return response
188
189 async def check_config(self) -> None:
190 """
191 Perform a one-off configuration check that StaticFiles is actually
192 pointed at a directory, so that we can raise loud errors rather than
193 just returning 404 responses.
194 """
195 if self.directory is None:
196 return
197
198 try:
199 stat_result = await anyio.to_thread.run_sync(os.stat, self.directory)
200 except FileNotFoundError:
201 raise RuntimeError(f"StaticFiles directory '{self.directory}' does not exist.")
202 if not (stat.S_ISDIR(stat_result.st_mode) or stat.S_ISLNK(stat_result.st_mode)):
203 raise RuntimeError(f"StaticFiles path '{self.directory}' is not a directory.")
204
205 def is_not_modified(self, response_headers: Headers, request_headers: Headers) -> bool:
206 """

Callers 1

__call__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected