Files
allmende-payment-system/main.py
2025-08-30 10:19:29 +02:00

23 lines
679 B
Python

from typing import Union, Annotated
from fastapi import FastAPI, Request, Depends
from fastapi.templating import Jinja2Templates
from fastapi.staticfiles import StaticFiles
from fastapi.security import OAuth2PasswordBearer
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
templates = Jinja2Templates(directory="templates")
@app.get("/")
async def read_root(request: Request):
return templates.TemplateResponse(
request=request, name="index.html"
)
@app.get("/protected")
async def read_item(token: Annotated[str, Depends(oauth2_scheme)]):
return {"token": token}