added authorization

This commit is contained in:
2025-11-16 15:27:51 +01:00
parent eeea1b2091
commit f5741ecc62
2 changed files with 39 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
from fastapi import FastAPI
from fastapi import FastAPI, Depends
from contextlib import asynccontextmanager
import database
import models
@@ -16,6 +16,10 @@ app = FastAPI(lifespan=lifespan)
async def root():
return {"message": "Hello World"}
@app.get("/me")
async def me(user: models.User = Depends(database.get_user_by_token)):
return user
@app.post("/users")
async def register(user: models.User):
database.register(user)