MCPcopy
hub / github.com/pallets/werkzeug / get_resource

Method get_resource

src/werkzeug/debug/__init__.py:420–435  ·  view source on GitHub ↗

Return a static resource from the shared folder.

(self, request: Request, filename: str)

Source from the content-addressed store, hash-verified

418 )
419
420 def get_resource(self, request: Request, filename: str) -> Response:
421 """Return a static resource from the shared folder."""
422 path = join("shared", basename(filename))
423
424 try:
425 data = pkgutil.get_data(__package__, path)
426 except OSError:
427 return NotFound() # type: ignore[return-value]
428 else:
429 if data is None:
430 return NotFound() # type: ignore[return-value]
431
432 etag = str(adler32(data) & 0xFFFFFFFF)
433 return send_file(
434 BytesIO(data), request.environ, download_name=filename, etag=etag
435 )
436
437 def check_pin_trust(self, environ: WSGIEnvironment) -> bool | None:
438 """Checks if the request passed the pin test. This returns `True` if the

Callers 1

__call__Method · 0.95

Calls 3

NotFoundClass · 0.85
send_fileFunction · 0.85
get_dataMethod · 0.45

Tested by

no test coverage detected