当前位置: 首页> 文旅> 文化 > 网络营销模式包括_公司logo设计含义_网络广告的概念_网络加速器

网络营销模式包括_公司logo设计含义_网络广告的概念_网络加速器

时间:2025/7/9 22:08:26来源:https://blog.csdn.net/lilongsy/article/details/145518471 浏览次数:0次
网络营销模式包括_公司logo设计含义_网络广告的概念_网络加速器

基于FastAPI Swagger UI的文档链接/docs/redoc在没有外网的状态下无法打开,原因是Swagger依赖的JS和CSS来自CDN。

https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-bundle.js
https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css
https://fastapi.tiangolo.com/img/favicon.png
https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js

FastAPI可以配置这些链接地址,改为本地目录下,自定义Javascript和CSS的CDN地址
在这里插入图片描述

from fastapi import FastAPI
from fastapi.openapi.docs import (get_redoc_html,get_swagger_ui_html,get_swagger_ui_oauth2_redirect_html,
)app = FastAPI(docs_url=None, redoc_url=None)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=app.openapi_url,title=app.title + " - Swagger UI",oauth2_redirect_url=app.swagger_ui_oauth2_redirect_url,swagger_js_url="/static/swagger-ui/swagger-ui-bundle.js",swagger_css_url="/static/swagger-ui/swagger-ui.css",swagger_favicon_url="/static/swagger-ui/favicon.png",)@app.get(app.swagger_ui_oauth2_redirect_url, include_in_schema=False)
async def swagger_ui_redirect():return get_swagger_ui_oauth2_redirect_html()@app.get("/redoc", include_in_schema=False)
async def redoc_html():return get_redoc_html(openapi_url=app.openapi_url,title=app.title + " - ReDoc",redoc_js_url="/static/redoc/redoc.standalone.js",redoc_favicon_url="/static/redoc/favicon.png",with_google_fonts=False)

文件下载地址:
https://download.csdn.net/download/lilongsy/90355890

相关链接

https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/

关键字:网络营销模式包括_公司logo设计含义_网络广告的概念_网络加速器

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: