import os from fastapi import FastAPI from fastapi.responses import HTMLResponse from jinja2 import Environment, FileSystemLoader import config app = FastAPI( title=config.Main.app_name, ) env = Environment( loader=FileSystemLoader( searchpath=os.path.join( config.Main.cwd, 'templates', ), ), enable_async=True, ) env.globals['app_name'] = config.Main.app_name @app.get( path='/', ) async def _(): template = env.get_template('main.jinja2') return HTMLResponse( content=await template.render_async( title='Дашборд', ), )