diff options
author | DepFA <35278260+dfaker@users.noreply.github.com> | 2022-10-01 21:43:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-01 21:43:45 +0000 |
commit | afaa03c5fd05f48ed9c9f15558ea6f0bc4f61628 (patch) | |
tree | cdcab0056b96ea58e1ea554830a8f32b2f0ef155 /modules/ui.py | |
parent | a9044475c06204deb886d2a69467d0d3a9f5c9be (diff) | |
download | stable-diffusion-webui-gfx803-afaa03c5fd05f48ed9c9f15558ea6f0bc4f61628.tar.gz stable-diffusion-webui-gfx803-afaa03c5fd05f48ed9c9f15558ea6f0bc4f61628.tar.bz2 stable-diffusion-webui-gfx803-afaa03c5fd05f48ed9c9f15558ea6f0bc4f61628.zip |
add redefinition guard to gradio_routes_templates_response
Diffstat (limited to 'modules/ui.py')
-rw-r--r-- | modules/ui.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/modules/ui.py b/modules/ui.py index ec6aaa28..fd057916 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -1219,12 +1219,13 @@ for filename in sorted(os.listdir(jsdir)): javascript += f"\n<script>{jsfile.read()}</script>"
-def template_response(*args, **kwargs):
- res = gradio_routes_templates_response(*args, **kwargs)
- res.body = res.body.replace(b'</head>', f'{javascript}</head>'.encode("utf8"))
- res.init_headers()
- return res
+if 'gradio_routes_templates_response' not in globals():
+ def template_response(*args, **kwargs):
+ res = gradio_routes_templates_response(*args, **kwargs)
+ res.body = res.body.replace(b'</head>', f'{javascript}</head>'.encode("utf8"))
+ res.init_headers()
+ return res
+ gradio_routes_templates_response = gradio.routes.templates.TemplateResponse
+ gradio.routes.templates.TemplateResponse = template_response
-gradio_routes_templates_response = gradio.routes.templates.TemplateResponse
-gradio.routes.templates.TemplateResponse = template_response
|