Skip to content

Commit

Permalink
Merge pull request #140 from gsarrco:feat/check-for-db-status-in-home
Browse files Browse the repository at this point in the history
Check for db status in home
  • Loading branch information
gsarrco authored Oct 15, 2023
2 parents a0922f0 + 11e13a4 commit 87ea814
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions MuoVErsi/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import uvicorn
import yaml
from babel.dates import format_date
from sqlalchemy import create_engine
from sqlalchemy import create_engine, text
from sqlalchemy.orm import sessionmaker
from starlette.applications import Starlette
from starlette.requests import Request
Expand Down Expand Up @@ -608,7 +608,17 @@ async def telegram(request: Request) -> Response:

async def home(request: Request) -> Response:
sources = thismodule.sources
text_response = '<html><ul>'
text_response = '<html>'

try:
sources['treni'].session.execute(text('SELECT 1'))
except Exception:
return Response(status_code=500)
else:
text_response += '<p>Postgres connection OK</p>'


text_response += '<ul>'
for source in sources.values():
if hasattr(source, 'gtfs_version'):
text_response += f'<li>{source.name}: GTFS v.{source.gtfs_version}</li>'
Expand Down

0 comments on commit 87ea814

Please sign in to comment.