Files
Wu Clan 865dfccf08 Add demo site mode (#173)
* Add demo site mode

* fix demo site whitelist
2023-07-07 17:55:56 +08:00

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='演示环境下禁止执行此操作')