mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-12-15 07:20:31 +08:00
add redefinition guard to gradio_routes_templates_response
This commit is contained in:
parent
a9044475c0
commit
afaa03c5fd
@ -1219,12 +1219,13 @@ for filename in sorted(os.listdir(jsdir)):
|
|||||||
javascript += f"\n<script>{jsfile.read()}</script>"
|
javascript += f"\n<script>{jsfile.read()}</script>"
|
||||||
|
|
||||||
|
|
||||||
def template_response(*args, **kwargs):
|
if 'gradio_routes_templates_response' not in globals():
|
||||||
res = gradio_routes_templates_response(*args, **kwargs)
|
def template_response(*args, **kwargs):
|
||||||
res.body = res.body.replace(b'</head>', f'{javascript}</head>'.encode("utf8"))
|
res = gradio_routes_templates_response(*args, **kwargs)
|
||||||
res.init_headers()
|
res.body = res.body.replace(b'</head>', f'{javascript}</head>'.encode("utf8"))
|
||||||
return res
|
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
|
|
||||||
|
Loading…
Reference in New Issue
Block a user