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

相关推荐
Python私教17 小时前
FastAPI+React19 ERP系统实战 第02期
fastapi
Python私教1 天前
FastAPI+React19 ERP系统实战 第01期
react·fastapi
小宁爱Python3 天前
FastAPI+Sqlite+HTML的登录注册与文件上传系统:完整实现指南
sqlite·html·fastapi
fairymt3 天前
LoRA 问答微调与部署全流程:基于 LLaMA-Factory + DeepSeek + FastAPI 打造专属大模型
fastapi
chenkangck5013 天前
Uvicorn 入门详解
python·fastapi
remandancy.h16 天前
FastAPI:(2)开启FastAPI
fastapi
里探17 天前
FastAPI的初步学习(Django用户过来的)
python·django·fastapi
从零开始学习人工智能17 天前
基于FastAPI与Selenium的智能开关状态管理系统实践
selenium·adb·fastapi
Python私教18 天前
FastAPI本地文档的定制技巧
fastapi
沛沛老爹20 天前
Celery+fastAPI/Flask实现高性能应用
python·flask·fastapi·celery·web框架集成