crappy
This commit is contained in:
21
main.py
21
main.py
@@ -1,11 +1,26 @@
|
||||
from fastapi import FastAPI
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import FastAPI, Depends
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.base import get_session
|
||||
from database.models import User
|
||||
import routers
|
||||
|
||||
app = FastAPI()
|
||||
routers_list = [
|
||||
routers.auth_router
|
||||
]
|
||||
for router in routers_list:
|
||||
app.include_router(router)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"message": "Hello World"}
|
||||
async def root(db_session: Annotated[AsyncSession, Depends(get_session)]):
|
||||
user: User = await db_session.scalar(select(User).where(User.id == 1))
|
||||
|
||||
return {"message": user.login}
|
||||
|
||||
|
||||
@app.get("/hello/{name}")
|
||||
|
||||
Reference in New Issue
Block a user