1+ from fastapi import requests
2+ from app .routers .hugs import Hug
13from fastapi import Request , FastAPI , Header , HTTPException
24from fastapi .templating import Jinja2Templates
35from fastapi .responses import HTMLResponse
4- from fastapi .staticfiles import StaticFiles
6+ from fastapi .staticfiles import StaticFiles
57from .routers import hugs
68
79
10+
811templates = Jinja2Templates (directory = "templates" )
912
13+
1014tags_metadata = [
1115 {
1216 "name" : "hugs" ,
2226 openapi_tags = tags_metadata ,
2327 title = "The super duper Hugs API" ,
2428 description = "This is an example for the base project Generator" ,
25- version = "0.0.0.0.0 .0.1" ,
29+ version = "v0 .0.1" ,
2630
2731)
2832
2933
34+
3035async def get_token_header (x_token : str = Header (...)):
3136 if x_token != "fake-super-secret-token" :
3237 raise HTTPException (status_code = 400 , detail = "X-Token header invalid" )
@@ -35,7 +40,7 @@ async def get_token_header(x_token: str = Header(...)):
3540app .include_router (hugs .router )
3641app .mount ("/static" , StaticFiles (directory = "static" ), name = "static" )
3742
38- @app .get ("/" )
43+ @app .get ("/" , response_class = HTMLResponse )
3944async def serve_home (request : Request ):
4045 return templates .TemplateResponse ("index.html" , {"request" : request })
4146
0 commit comments