fastapi给文档页面docs/加锁

加锁后效果如下:

如图docs/页面打开默认是茶壶,需加上定制参数才能正常访问 :

具体实现如下:

  1. 安装依赖包:
bash 复制代码
pip install 'fastapi-cdn-host>=0.5.2' || pip install --upgrade git+ssh://git@github.com/waketzheng/fastapi-cdn-host
  1. 启用文档锁:
python 复制代码
import fastapi_cdn_host
from fastapi import FastAPI


app = FastAPI(openapi_url="/api/v1/openapi.json")
fastapi_cdn_host.patch_docs(app, lock=fastapi_cdn_host.weekday_lock)

更多示例见:fastapi-cdn-host/tests/lock_docs/main.py at main · waketzheng/fastapi-cdn-host · GitHub

相关推荐
CaffeinePro3 天前
Pydantic深度使用:数据校验、枚举、ORM映射
后端·fastapi
jay神5 天前
基于 FastAPI + Vue 的宠物领养管理系统
前端·vue.js·python·毕业设计·fastapi·宠物
染指11106 天前
6.AI大模型-搭建本地大模型服务体系
fastapi·oneapi
codeaideaai7 天前
使用UV创建python项目
python·fastapi·uv
放下华子我只抽RuiKe58 天前
FastAPI 全栈后端(八):部署与运维
运维·数据库·react.js·oracle·数据挖掘·前端框架·fastapi
SilentSamsara8 天前
模型部署实战:FastAPI + ONNX + Docker 的推理服务化
人工智能·pytorch·python·深度学习·机器学习·fastapi
放下华子我只抽RuiKe58 天前
FastAPI 全栈后端(七):测试与自动化
运维·前端·人工智能·react.js·前端框架·自动化·fastapi
abcy0712138 天前
Python中使用FastAPI和HDFS进行异步文件上传
python·fastapi
江华森8 天前
FastAPI 极速开发指南 — 从零到生产级 API 实战
数据库·fastapi
放下华子我只抽RuiKe58 天前
FastAPI 全栈后端(三):数据库与 ORM
前端·数据库·react.js·oracle·性能优化·前端框架·fastapi