根源就是js和ccs文件访问路由的问题,首先你要有本地的文件,详情看https://qq742971636.blog.csdn.net/article/details/134587010。
其次,你需要这么写:
/unicontorlblip就是我配置的mLB网关路由。
app = FastAPI(
title='outpainting_captioning_upscaler',
description='outpainting images, captioning images,upscaler images',
version='1.0.0',
docs_url=None,
redoc_url=None, # 设置 ReDoc 文档的路径
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.mount("/static", StaticFiles(directory="static"), name="static")
@app.get("/docs", include_in_schema=False)
async def custom_swagger_ui_html():
return get_swagger_ui_html(
openapi_url="/unicontorlblip/openapi.json",
title="xx",
# oauth2_redirect_url=app.swagger_ui_oauth2_redirect_url,
swagger_js_url='/unicontorlblip/static/swagger/swagger-ui-bundle.js',
swagger_css_url='/unicontorlblip/static/swagger/swagger-ui.css',
swagger_favicon_url='/unicontorlblip/static/swagger/img.png',
)