Files
fastapi-best-architecture/backend/utils/demo_site.py
T
Wu Clan 5762834744 Update the ruff rules and format the code (#846)
* Update the ruff rules and format the code

* Update the per-file-ignores

* Update the ci

* Update rules

* Fix codes

* Fix pagination

* Update rules
2025-10-10 19:02:49 +08:00

23 lines
565 B
Python

from fastapi import Request
from backend.common.exception import errors
from backend.core.conf import settings
async def demo_site(request: Request) -> None: # noqa: RUF029
"""
演示站点
: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='演示环境下禁止执行此操作')