MCPcopy
hub / github.com/pallets/flask / send_static_file

Method send_static_file

src/flask/app.py:308–328  ·  view source on GitHub ↗

The view function used to serve files from :attr:`static_folder`. A route is automatically registered for this view at :attr:`static_url_path` if :attr:`static_folder` is set. Note this is a duplicate of the same method in the Flask class. .. version

(self, filename: str)

Source from the content-addressed store, hash-verified

306 return value # type: ignore[no-any-return]
307
308 def send_static_file(self, filename: str) -> Response:
309 """The view function used to serve files from
310 :attr:`static_folder`. A route is automatically registered for
311 this view at :attr:`static_url_path` if :attr:`static_folder` is
312 set.
313
314 Note this is a duplicate of the same method in the Flask
315 class.
316
317 .. versionadded:: 0.5
318
319 """
320 if not self.has_static_folder:
321 raise RuntimeError("'static_folder' must be set to serve static_files.")
322
323 # send_file only knows to call get_send_file_max_age on the app,
324 # call it here so it works for blueprints too.
325 max_age = self.get_send_file_max_age(filename)
326 return send_from_directory(
327 t.cast(str, self.static_folder), filename, max_age=max_age
328 )
329
330 def open_resource(
331 self, resource: str, mode: str = "rb", encoding: str | None = None

Callers 3

__init__Method · 0.45
test_static_fileMethod · 0.45

Calls 2

get_send_file_max_ageMethod · 0.95
send_from_directoryFunction · 0.85

Tested by 2

test_static_fileMethod · 0.36