fastapi给文档页面docs/加锁

加锁后效果如下:

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

具体实现如下:

  1. 安装依赖包:
bash 复制代码
pip install 'fastapi-cdn-host>=0.5.2' || pip install --upgrade git+ssh://[email protected]/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

相关推荐
zizle_lin19 小时前
优雅使用Gunicorn进程管理FastAPI
服务器·fastapi·gunicorn
掘金-我是哪吒3 天前
分布式微服务系统架构第131集:fastapi-python
分布式·python·微服务·系统架构·fastapi
Anesthesia丶5 天前
Vue3 + naive-ui + fastapi使用心得
vue.js·ui·fastapi
weixin_307779135 天前
使用FastAPI微服务在AWS EKS中构建上下文增强型AI问答系统
人工智能·python·云计算·fastapi·aws
掘金-我是哪吒5 天前
分布式微服务系统架构第130集:Python工程化FastAPI,运维Nginx-keepalived+Nginx实现高可用集群
运维·分布式·微服务·系统架构·fastapi
LingRannn5 天前
JWT的介绍与在Fastapi框架中的应用
fastapi
Python私教6 天前
使用FastAPI和React以及MongoDB构建全栈Web应用05 FastAPI快速入门
前端·react.js·fastapi
Python私教6 天前
全栈开发实战:FastAPI + React + MongoDB 构建现代Web应用
前端·react.js·fastapi
weixin_307779137 天前
使用FastAPI和Apache Flink构建跨环境数据管道
redis·python·云计算·fastapi·aws
真智AI10 天前
构建安全的机器学习推理API:基于FastAPI的用户认证与管理实战
安全·机器学习·fastapi