Spaces:
Sleeping
Sleeping
Upload RadGenome demo Space
Browse files
app.py
CHANGED
|
@@ -48,6 +48,18 @@ def _patch_template_response_compat():
|
|
| 48 |
original_template_response = gradio_routes.templates.TemplateResponse
|
| 49 |
|
| 50 |
def safe_template_response(*args, **kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
if not args and {"request", "name", "context"} <= set(kwargs):
|
| 52 |
request = kwargs["request"]
|
| 53 |
name = kwargs["name"]
|
|
|
|
| 48 |
original_template_response = gradio_routes.templates.TemplateResponse
|
| 49 |
|
| 50 |
def safe_template_response(*args, **kwargs):
|
| 51 |
+
# Old-style positional call: TemplateResponse(name_str, context_dict)
|
| 52 |
+
# New Starlette interprets this as (request=name_str, name=context_dict),
|
| 53 |
+
# causing "unhashable type: 'dict'" when Jinja2 tries to cache on `name`.
|
| 54 |
+
if args and isinstance(args[0], str) and len(args) >= 2 and isinstance(args[1], dict):
|
| 55 |
+
name = args[0]
|
| 56 |
+
context = dict(args[1])
|
| 57 |
+
request = context.get("request")
|
| 58 |
+
try:
|
| 59 |
+
return original_template_response(request=request, name=name, context=context)
|
| 60 |
+
except Exception:
|
| 61 |
+
return original_template_response(name, context, *args[2:], **kwargs)
|
| 62 |
+
|
| 63 |
if not args and {"request", "name", "context"} <= set(kwargs):
|
| 64 |
request = kwargs["request"]
|
| 65 |
name = kwargs["name"]
|