anonymous-IA commited on
Commit
ee3433a
·
verified ·
1 Parent(s): 0b93ab8

Upload 41 files

Browse files
Files changed (2) hide show
  1. __pycache__/app.cpython-310.pyc +0 -0
  2. app.py +20 -0
__pycache__/app.cpython-310.pyc CHANGED
Binary files a/__pycache__/app.cpython-310.pyc and b/__pycache__/app.cpython-310.pyc differ
 
app.py CHANGED
@@ -13,6 +13,26 @@ except ImportError:
13
  import os
14
  from functools import lru_cache
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  import gradio as gr
17
 
18
  # Gradio 4.44 can encounter JSON-schema ``additionalProperties: false`` in
 
13
  import os
14
  from functools import lru_cache
15
 
16
+ # Gradio 4.44 calls Starlette's template API using its pre-0.29 signature.
17
+ # Some current Space base images provide the newer signature instead.
18
+ import starlette.templating as _starlette_templating
19
+ _original_template_response = _starlette_templating.Jinja2Templates.TemplateResponse
20
+
21
+ def _compatible_template_response(self, *args, **kwargs):
22
+ if args and isinstance(args[0], str) and len(args) >= 2 and isinstance(args[1], dict):
23
+ template = self.get_template(args[0])
24
+ return _starlette_templating._TemplateResponse(
25
+ template,
26
+ args[1],
27
+ status_code=args[2] if len(args) > 2 else kwargs.get("status_code", 200),
28
+ headers=kwargs.get("headers"),
29
+ media_type=kwargs.get("media_type"),
30
+ background=kwargs.get("background"),
31
+ )
32
+ return _original_template_response(self, *args, **kwargs)
33
+
34
+ _starlette_templating.Jinja2Templates.TemplateResponse = _compatible_template_response
35
+
36
  import gradio as gr
37
 
38
  # Gradio 4.44 can encounter JSON-schema ``additionalProperties: false`` in