This action will force synchronization from zero/WaitAdmin开源后台系统(Python版), which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
# +----------------------------------------------------------------------# | WaitAdmin(fastapi)快速开发后台管理系统# +----------------------------------------------------------------------# | 欢迎阅读学习程序代码,建议反馈是我们前进的动力# | 程序完全开源可支持商用,允许去除界面版权信息# | gitee: https://gitee.com/wafts/waitadmin-python# | github: https://github.com/topwait/waitadmin-python# | 官方网站: https://www.waitadmin.cn# | WaitAdmin团队版权所有并拥有最终解释权# +----------------------------------------------------------------------# | Author: WaitAdmin Team <2474369941@qq.com># +----------------------------------------------------------------------import typingimport asynciofrom abc import ABCfrom fastapi import FastAPIfrom fastapi.responses import JSONResponsefrom fastapi.middleware.cors import CORSMiddlewarefrom starlette.middleware.base import BaseHTTPMiddlewarefrom starlette.types import ASGIAppdef init_middlewares(app: FastAPI):# 跨域中间件cors_middleware: typing.Type[any] = CORSMiddlewareapp.add_middleware(cors_middleware,allow_credentials=True,allow_origins=["*"],allow_methods=["*"],allow_headers=["*"])# 超时中间件timeout_middleware: typing.Type[any] = TimeoutMiddlewareapp.add_middleware(timeout_middleware, timeout=500)class TimeoutMiddleware(BaseHTTPMiddleware, ABC):def __init__(self, app: ASGIApp, timeout: int = 15):super().__init__(app)self.timeout = timeoutasync def dispatch(self, request, call_next):try:return await asyncio.wait_for(call_next(request), timeout=self.timeout)except asyncio.TimeoutError:return JSONResponse({"code": 1, "msg": "Request timeout", "data": []})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。