Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
9a33292c
Commit
9a33292c
authored
Oct 14, 2022
by
zhengxiaoyao0716
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reload javascript files when custom script bodies
parent
be1596ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
ui.py
modules/ui.py
+16
-12
No files found.
modules/ui.py
View file @
9a33292c
...
@@ -12,7 +12,7 @@ import time
...
@@ -12,7 +12,7 @@ import time
import
traceback
import
traceback
import
platform
import
platform
import
subprocess
as
sp
import
subprocess
as
sp
from
functools
import
reduce
from
functools
import
partial
,
reduce
import
numpy
as
np
import
numpy
as
np
import
torch
import
torch
...
@@ -1491,6 +1491,7 @@ Requested path was: {f}
...
@@ -1491,6 +1491,7 @@ Requested path was: {f}
def
reload_scripts
():
def
reload_scripts
():
modules
.
scripts
.
reload_script_body_only
()
modules
.
scripts
.
reload_script_body_only
()
reload_javascript
()
# need to refresh the html page
reload_script_bodies
.
click
(
reload_script_bodies
.
click
(
fn
=
reload_scripts
,
fn
=
reload_scripts
,
...
@@ -1738,22 +1739,25 @@ Requested path was: {f}
...
@@ -1738,22 +1739,25 @@ Requested path was: {f}
return
demo
return
demo
with
open
(
os
.
path
.
join
(
script_path
,
"script.js"
),
"r"
,
encoding
=
"utf8"
)
as
jsfile
:
def
load_javascript
(
raw_response
):
javascript
=
f
'<script>{jsfile.read()}</script>'
with
open
(
os
.
path
.
join
(
script_path
,
"script.js"
),
"r"
,
encoding
=
"utf8"
)
as
jsfile
:
javascript
=
f
'<script>{jsfile.read()}</script>'
jsdir
=
os
.
path
.
join
(
script_path
,
"javascript"
)
jsdir
=
os
.
path
.
join
(
script_path
,
"javascript"
)
for
filename
in
sorted
(
os
.
listdir
(
jsdir
)):
for
filename
in
sorted
(
os
.
listdir
(
jsdir
)):
with
open
(
os
.
path
.
join
(
jsdir
,
filename
),
"r"
,
encoding
=
"utf8"
)
as
jsfile
:
with
open
(
os
.
path
.
join
(
jsdir
,
filename
),
"r"
,
encoding
=
"utf8"
)
as
jsfile
:
javascript
+=
f
"
\n
<script>{jsfile.read()}</script>"
javascript
+=
f
"
\n
<!-- {filename} -->
<script>{jsfile.read()}</script>"
if
'gradio_routes_templates_response'
not
in
globals
():
def
template_response
(
*
args
,
**
kwargs
):
def
template_response
(
*
args
,
**
kwargs
):
res
=
gradio_routes_templates_response
(
*
args
,
**
kwargs
)
res
=
raw_response
(
*
args
,
**
kwargs
)
res
.
body
=
res
.
body
.
replace
(
b
'</head>'
,
f
'{javascript}</head>'
.
encode
(
"utf8"
))
res
.
body
=
res
.
body
.
replace
(
b
'</head>'
,
f
'{javascript}</head>'
.
encode
(
"utf8"
))
res
.
init_headers
()
res
.
init_headers
()
return
res
return
res
gradio_routes_templates_response
=
gradio
.
routes
.
templates
.
TemplateResponse
gradio
.
routes
.
templates
.
TemplateResponse
=
template_response
gradio
.
routes
.
templates
.
TemplateResponse
=
template_response
reload_javascript
=
partial
(
load_javascript
,
gradio
.
routes
.
templates
.
TemplateResponse
)
reload_javascript
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment