mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2025-08-18 06:42:51 +08:00
21 lines
532 B
Python
21 lines
532 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from fastapi import Request
|
|
|
|
from backend.app.common.exception import errors
|
|
from backend.app.core.conf import settings
|
|
|
|
|
|
async def demo_site(request: Request):
|
|
"""演示站点"""
|
|
|
|
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='演示环境下禁止执行此操作')
|