To create a public link, set share=True
in launch()
.
Traceback (most recent call last):
File "D:\SD\stable-diffusion-webui-1.0.0-pre\launch.py", line 330, in
start()
File "D:\SD\stable-diffusion-webui-1.0.0-pre\launch.py", line 325, in start
webui.webui()
File "D:\SD\stable-diffusion-webui-1.0.0-pre\webui.py", line 224, in webui
app.add_middleware(GZipMiddleware, minimum_size=1000)
File "D:\SD\stable-diffusion-webui-1.0.0-pre\venv\lib\site-packages\starlette\applications.py", line 135, in add_middleware
raise RuntimeError("Cannot add middleware after an application has started")
RuntimeError: Cannot add middleware after an application has started
试下 open .打开SD所在文件夹,在stable-diffusion-webui文件夹中的requirements_versions.txt 文件中添加“fastapi==0.90.1”
按照这个办法 https://zhuanlan.zhihu.com/p/608178376
这个错误的原因是,在应用程序启动后,无法添加中间件。在你的代码中,你尝试在应用程序启动后添加中间件,导致了这个错误。要解决这个问题,你需要在应用程序启动前添加中间件。
建议将添加中间件的代码放在webui()函数的开头,如下所示:
def webui():
app = Starlette(debug=True)
# 添加中间件
app.add_middleware(GZipMiddleware, minimum_size=1000)
# 其他代码
# ...
这样就可以在应用程序启动前添加中间件,避免了这个错误。