Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
1b91cbbc
Commit
1b91cbbc
authored
Oct 19, 2022
by
AUTOMATIC1111
Committed by
GitHub
Oct 19, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2835 from zhengxiaoyao0716/hot-reload-javascript
hot-reload javascript files
parents
1d4aa376
05315d8a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
14 deletions
+19
-14
modules/ui.py
modules/ui.py
+19
-14
No files found.
modules/ui.py
View file @
1b91cbbc
...
...
@@ -12,7 +12,7 @@ import time
import
traceback
import
platform
import
subprocess
as
sp
from
functools
import
reduce
from
functools
import
partial
,
reduce
import
numpy
as
np
import
torch
...
...
@@ -1558,6 +1558,7 @@ Requested path was: {f}
def
reload_scripts
():
modules
.
scripts
.
reload_script_body_only
()
reload_javascript
()
# need to refresh the html page
reload_script_bodies
.
click
(
fn
=
reload_scripts
,
...
...
@@ -1816,26 +1817,30 @@ Requested path was: {f}
return
demo
with
open
(
os
.
path
.
join
(
script_path
,
"script.js"
),
"r"
,
encoding
=
"utf8"
)
as
jsfile
:
javascript
=
f
'<script>{jsfile.read()}</script>'
def
load_javascript
(
raw_response
):
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"
)
for
filename
in
sorted
(
os
.
listdir
(
jsdir
)):
with
open
(
os
.
path
.
join
(
jsdir
,
filename
),
"r"
,
encoding
=
"utf8"
)
as
jsfile
:
javascript
+=
f
"
\n
<script>{jsfile.read()}</script>"
jsdir
=
os
.
path
.
join
(
script_path
,
"javascript"
)
for
filename
in
sorted
(
os
.
listdir
(
jsdir
)):
with
open
(
os
.
path
.
join
(
jsdir
,
filename
),
"r"
,
encoding
=
"utf8"
)
as
jsfile
:
javascript
+=
f
"
\n
<!-- {filename} -->
<script>{jsfile.read()}</script>"
if
cmd_opts
.
theme
is
not
None
:
javascript
+=
f
"
\n
<script>set_theme('{cmd_opts.theme}');</script>
\n
"
if
cmd_opts
.
theme
is
not
None
:
javascript
+=
f
"
\n
<script>set_theme('{cmd_opts.theme}');</script>
\n
"
javascript
+=
f
"
\n
<script>{localization.localization_js(shared.opts.localization)}</script>"
javascript
+=
f
"
\n
<script>{localization.localization_js(shared.opts.localization)}</script>"
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
=
raw_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
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