mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2025-08-14 19:04:00 +08:00
25 lines
596 B
Python
25 lines
596 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from fastapi import Request
|
|
|
|
from backend.common.exception import errors
|
|
from backend.core.conf import settings
|
|
|
|
|
|
async def demo_site(request: Request) -> None:
|
|
"""
|
|
演示站点
|
|
|
|
:param request: FastAPI 请求对象
|
|
:return:
|
|
"""
|
|
method = request.method
|
|
path = request.url.path
|
|
if (
|
|
settings.DEMO_MODE
|
|
and method != 'GET'
|
|
and method != 'OPTIONS'
|
|
and (method, path) not in settings.DEMO_MODE_EXCLUDE
|
|
):
|
|
raise errors.ForbiddenError(msg='演示环境下禁止执行此操作')
|