You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.3 KiB

from datetime import timedelta
from fastapi.security import OAuth2PasswordRequestForm
from fastapi import Depends, FastAPI, HTTPException, status
from dependencies import *
from internal.models import Token
from fastapi.middleware.cors import CORSMiddleware
from slowapi.middleware import SlowAPIMiddleware
from slowapi import _rate_limit_exceeded_handler
from limiter_config import limiter
from routers import bloglabel, blogtype, usermanage,blogmanage,classticmanage,commonlinkmanage,diarymanage,diarytype,statistic,disbursemanage,photomanage,commentmanage
app=FastAPI()
app.state.limiter = limiter
app.add_exception_handler(429, _rate_limit_exceeded_handler)
app.add_middleware(SlowAPIMiddleware)
app.include_router(usermanage.router)
app.include_router(blogtype.router)
app.include_router(blogmanage.router)
app.include_router(diarymanage.router)
app.include_router(diarytype.router)
app.include_router(classticmanage.router)
app.include_router(commonlinkmanage.router)
app.include_router(bloglabel.router)
app.include_router(statistic.router)
app.include_router(disbursemanage.router)
app.include_router(photomanage.router)
app.include_router(commentmanage.router)
# 解决跨域
app.add_middleware(
CORSMiddleware,
allow_origins=['*'],
allow_credentials=True,
allow_methods=['GET', 'POST','DELETE','PUT'],
allow_headers=['*'],
)