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 scripts.basedir() than prompt_gallery_name.json #23

Open leohu1 opened 1 year ago

leohu1 commented 1 year ago

Use scripts.basedir() than prompt_gallery_name.json I think it's simpler, don't you? 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)
dr413677671 commented 1 year ago

Tried outside of func. Do not works. Did you try and test it?

leohu1 commented 1 year ago

Yes, I did. It works for me.

dr413677671 commented 1 year ago

It certainly do not work on my side. I tried copy paste the code just like you said. It still do not return root path of webui. Could you paste the debug outputs here?