File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import os
2+ import logging
23import pathlib
34from datetime import datetime
45
1213
1314from .models import Restaurant , Review , engine
1415
16+ logging .basicConfig (level = logging .DEBUG )
17+
1518if os .getenv ("APPLICATIONINSIGHTS_CONNECTION_STRING" ):
1619 configure_azure_monitor ()
1720
21+ print ("Setting up FastAPI app..." )
22+ logging .warning ("From logging: Setting up FastAPI app..." )
23+
1824app = FastAPI ()
1925parent_path = pathlib .Path (__file__ ).parent .parent
2026app .mount ("/mount" , StaticFiles (directory = parent_path / "static" ), name = "static" )
2329# Use relative path for url_for, so that it works behind a proxy like Codespaces
2430templates .env .globals ["url_for" ] = app .url_path_for
2531
26-
2732# Dependency to get the database session
2833def get_db_session ():
2934 with Session (engine ) as session :
@@ -33,6 +38,7 @@ def get_db_session():
3338@app .get ("/" , response_class = HTMLResponse )
3439async def index (request : Request , session : Session = Depends (get_db_session )):
3540 print ("root called" )
41+ logging .warning ("From logging: root called" )
3642 statement = (
3743 select (Restaurant , func .avg (Review .rating ).label ("avg_rating" ), func .count (Review .id ).label ("review_count" ))
3844 .outerjoin (Review , Review .restaurant == Restaurant .id )
You can’t perform that action at this time.
0 commit comments