dr413677671 / PromptGallery-stable-diffusion-webui

A prompt cookbook worked as stable-diffusion-webui extenstions.
Apache License 2.0
153 stars 16 forks source link

[Enhancement] Use only the same Port and IP as Stable-Diffusion-WebUI #19

Open leohu1 opened 1 year ago

leohu1 commented 1 year ago

I think it's better to use the same FastApi class by on_app_started(demo: Optional[Blocks], app: FastAPI)then to start a new server. I tried to do it, but I don't have the source code of the front-end, so I can't do it.

dr413677671 commented 1 year ago

It should be ok as long as it is called before tab init. From my point of view UI service starts in ui settings.

leohu1 commented 1 year ago

Like this:

extension_dir = scripts.basedir()
# don't use scripts.basedir() in function, or it will return the rootpath of webui.

def on_app_started(demo: Optional[gr.Blocks], app: FastAPI):
    app.mount('/prompt_gallery', StaticFiles(directory=extension_dir,html=True))    

modules.script_callbacks.on_app_started(on_app_started)