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
50059ea6
Commit
50059ea6
authored
Jan 21, 2023
by
James Tolton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server individually listed javascript files vs single compiled file
parent
17af0fb9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
32 deletions
+23
-32
ui.py
modules/ui.py
+23
-29
put-static-files-here.txt
statica/put-static-files-here.txt
+0
-1
webui.py
webui.py
+0
-2
No files found.
modules/ui.py
View file @
50059ea6
...
@@ -1919,47 +1919,41 @@ def create_ui():
...
@@ -1919,47 +1919,41 @@ def create_ui():
def
reload_javascript
():
def
reload_javascript
():
javascript_files
=
OrderedDict
()
with
open
(
os
.
path
.
join
(
script_path
,
"script.js"
),
"r"
,
encoding
=
"utf8"
)
as
jsfile
:
contents
=
jsfile
.
read
()
javascript_files
[
"script.js"
]
=
[
contents
]
scripts_list
=
modules
.
scripts
.
list_scripts
(
"javascript"
,
".js"
)
scripts_list
=
modules
.
scripts
.
list_scripts
(
"javascript"
,
".js"
)
js_files
=
[]
for
basedir
,
filename
,
path
in
scripts_list
:
for
basedir
,
filename
,
path
in
scripts_list
:
with
open
(
path
,
"r"
,
encoding
=
"utf8"
)
as
jsfile
:
path
=
path
[
len
(
script_path
)
+
1
:]
contents
=
jsfile
.
read
()
js_files
.
append
(
path
)
javascript_files
[
filename
]
=
[
contents
]
inline
=
[
f
"{localization.localization_js(shared.opts.localization)};"
]
if
cmd_opts
.
theme
is
not
None
:
if
cmd_opts
.
theme
is
not
None
:
javascript_files
[
"theme.js"
]
=
[
f
"set_theme('{cmd_opts.theme}');"
]
inline
.
append
(
f
"set_theme('{cmd_opts.theme}');"
,
)
javascript_files
[
"localization.js"
]
=
[
f
"{localization.localization_js(shared.opts.localization)}"
]
t
=
int
(
time
.
time
())
head
=
[
compiled_name
=
"webui-compiled.js"
f
"""
head
=
f
"""
<script type="text/javascript" src="file=./script.js?{t}"></script>
<script src=/statica/{compiled_name}?{int(time.time())} type="text/javascript"></script>
"""
.
strip
()
"""
]
inline_code
=
"
\n
"
.
join
(
inline
)
head
.
append
(
f
"""
<script type="text/javascript">
{inline_code}
</script>
"""
.
strip
())
for
file
in
js_files
:
head
.
append
(
f
"""
<script type="text/javascript" src="file={file}?{t}"></script>
"""
.
strip
())
def
template_response
(
*
args
,
**
kwargs
):
def
template_response
(
*
args
,
**
kwargs
):
res
=
shared
.
GradioTemplateResponseOriginal
(
*
args
,
**
kwargs
)
res
=
shared
.
GradioTemplateResponseOriginal
(
*
args
,
**
kwargs
)
head_inject
=
"
\n
"
.
join
(
head
)
res
.
body
=
res
.
body
.
replace
(
res
.
body
=
res
.
body
.
replace
(
b
'</head>'
,
f
'{head}</head>'
.
encode
(
"utf8"
))
b
'</head>'
,
f
'{head
_inject
}</head>'
.
encode
(
"utf8"
))
res
.
init_headers
()
res
.
init_headers
()
return
res
return
res
for
k
in
javascript_files
:
javascript_files
[
k
]
=
"
\n
"
.
join
(
javascript_files
[
k
])
# make static_path if not exists
statica_path
=
os
.
path
.
join
(
script_path
,
'statica'
)
if
not
os
.
path
.
exists
(
statica_path
):
os
.
mkdir
(
statica_path
)
javascript_out
=
"
\n\n\n
"
.
join
([
f
"// <!-- {k} -->
\n\n
{v}"
for
k
,
v
in
javascript_files
.
items
()])
with
open
(
os
.
path
.
join
(
script_path
,
"statica"
,
compiled_name
),
"w"
,
encoding
=
"utf8"
)
as
jsfile
:
jsfile
.
write
(
javascript_out
)
gradio
.
routes
.
templates
.
TemplateResponse
=
template_response
gradio
.
routes
.
templates
.
TemplateResponse
=
template_response
...
...
statica/put-static-files-here.txt
deleted
100644 → 0
View file @
17af0fb9
ayo
\ No newline at end of file
webui.py
View file @
50059ea6
...
@@ -8,7 +8,6 @@ import re
...
@@ -8,7 +8,6 @@ import re
from
fastapi
import
FastAPI
from
fastapi
import
FastAPI
from
fastapi.middleware.cors
import
CORSMiddleware
from
fastapi.middleware.cors
import
CORSMiddleware
from
fastapi.middleware.gzip
import
GZipMiddleware
from
fastapi.middleware.gzip
import
GZipMiddleware
from
starlette.staticfiles
import
StaticFiles
from
modules
import
import_hook
,
errors
,
extra_networks
from
modules
import
import_hook
,
errors
,
extra_networks
from
modules
import
extra_networks_hypernet
,
ui_extra_networks_hypernets
,
ui_extra_networks_textual_inversion
from
modules
import
extra_networks_hypernet
,
ui_extra_networks_hypernets
,
ui_extra_networks_textual_inversion
...
@@ -196,7 +195,6 @@ def webui():
...
@@ -196,7 +195,6 @@ def webui():
setup_cors
(
app
)
setup_cors
(
app
)
app
.
add_middleware
(
GZipMiddleware
,
minimum_size
=
1000
)
app
.
add_middleware
(
GZipMiddleware
,
minimum_size
=
1000
)
app
.
mount
(
"/statica"
,
StaticFiles
(
directory
=
os
.
path
.
join
(
script_path
,
'statica'
)),
name
=
"statica"
)
modules
.
progress
.
setup_progress_api
(
app
)
modules
.
progress
.
setup_progress_api
(
app
)
...
...
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