mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: init auth across the app
This commit is contained in:
parent
9479a4b127
commit
3b85a73ec1
12 changed files with 204 additions and 29 deletions
16
app.py
16
app.py
|
|
@ -1,6 +1,9 @@
|
|||
from urllib.request import Request
|
||||
from fastapi import FastAPI
|
||||
from src.main import global_router
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi_jwt_auth.exceptions import AuthJWTException
|
||||
|
||||
########################
|
||||
# Pre-Alpha Version 0.1.0
|
||||
|
|
@ -8,7 +11,8 @@ from fastapi.middleware.cors import CORSMiddleware
|
|||
# (c) LearnHouse 2022
|
||||
########################
|
||||
|
||||
# Init
|
||||
#
|
||||
# Global Config
|
||||
app = FastAPI(
|
||||
title="LearnHouse",
|
||||
description="LearnHouse is a new open-source platform tailored for learning experiences.",
|
||||
|
|
@ -24,8 +28,16 @@ app.add_middleware(
|
|||
allow_headers=["*"]
|
||||
)
|
||||
|
||||
app.include_router(global_router)
|
||||
#
|
||||
# Exception Handler
|
||||
@app.exception_handler(AuthJWTException)
|
||||
def authjwt_exception_handler(request: Request, exc: AuthJWTException):
|
||||
return JSONResponse(
|
||||
status_code=exc.status_code,
|
||||
content={"detail": exc.message}
|
||||
)
|
||||
|
||||
app.include_router(global_router)
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue