Return a static resource from the shared folder.
(self, request: Request, filename: str)
| 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 |