Skip to content

Instantly share code, notes, and snippets.

from starlette.templating import Jinja2Templates
from .template_env import timesince, price_format, bot_insert, get_flashed_messages
templates = Jinja2Templates(directory="app/templates")
templates.env.filters.update({"timesince": timesince,
"price_format": price_format})
templates.env.globals.update({"bot_insert": bot_insert,
"get_flashed_messages": get_flashed_messages})
from fastapi import FastAPI
app = FastAPI()
@app.get('/')
def index(request: Request, db: Session = Depends(get_db),
current_user: models.User = Depends(current_user)):
users = crud.get_channels(db, skip=0, limit=100)
return templates.TemplateResponse('index.html', {"title": 'home',
"users": users,
"request": request,
"current_user": current_user