(
self, dash_app: Dash, package_name: str, fingerprinted_path: str
)
| 198 | dash_app._add_url("", index, methods=["GET"]) |
| 199 | |
| 200 | def serve_component_suites( |
| 201 | self, dash_app: Dash, package_name: str, fingerprinted_path: str |
| 202 | ): |
| 203 | path_in_pkg, has_fingerprint = check_fingerprint(fingerprinted_path) |
| 204 | _validate.validate_js_path(dash_app.registered_paths, package_name, path_in_pkg) |
| 205 | extension = "." + path_in_pkg.split(".")[-1] |
| 206 | mimetype = mimetypes.types_map.get(extension, "application/octet-stream") |
| 207 | package = sys.modules[package_name] |
| 208 | dash_app.logger.debug( |
| 209 | "serving -- package: %s[%s] resource: %s => location: %s", |
| 210 | package_name, |
| 211 | package.__version__, |
| 212 | path_in_pkg, |
| 213 | package.__path__, |
| 214 | ) |
| 215 | data = pkgutil.get_data(package_name, path_in_pkg) |
| 216 | response = Response(data, mimetype=mimetype) |
| 217 | if has_fingerprint: |
| 218 | response.cache_control.max_age = 31536000 # 1 year |
| 219 | else: |
| 220 | response.add_etag() |
| 221 | tag = response.get_etag()[0] |
| 222 | request_etag = request.headers.get("If-None-Match") |
| 223 | if f'"{tag}"' == request_etag: |
| 224 | response = Response(None, status=304) |
| 225 | return response |
| 226 | |
| 227 | def setup_component_suites(self, dash_app: Dash): |
| 228 | def serve(package_name, fingerprinted_path): |
no test coverage detected