jgrivolla commited on
Commit
16cdb78
·
1 Parent(s): 4242ae5

make page title configurable

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -13,10 +13,14 @@ import time
13
  from dbutils.pooled_db import PooledDB
14
  import os
15
  import logging
 
16
 
17
  # Add this line to define the AUSLEIHE_TABLE variable
18
  AUSLEIHE_TABLE = os.environ.get('AUSLEIHE_TABLE', 'ausleihe_test')
19
 
 
 
 
20
  # Create a connection pool
21
  db_config = {
22
  'host': os.environ['MURMEL_DB_HOST'],
@@ -49,6 +53,8 @@ def execute_query(sql, params=None, max_retries=3, retry_delay=1):
49
  if 'connection' in locals():
50
  connection.close()
51
 
 
 
52
  @app.get("/groups")
53
  def get_groups():
54
  sql = "SELECT Gruppe, idGruppe FROM `gruppe` WHERE aktuell is True ORDER BY idGruppe ASC;"
@@ -147,11 +153,8 @@ def ausgeliehen(idKind):
147
  return result
148
 
149
  @app.get("/", response_class=HTMLResponse)
150
- async def read_root():
151
- with open("index.html", "r") as f:
152
- content = f.read()
153
- return HTMLResponse(content=content)
154
-
155
 
156
  # run the app
157
  if __name__ == '__main__':
 
13
  from dbutils.pooled_db import PooledDB
14
  import os
15
  import logging
16
+ from fastapi.templating import Jinja2Templates
17
 
18
  # Add this line to define the AUSLEIHE_TABLE variable
19
  AUSLEIHE_TABLE = os.environ.get('AUSLEIHE_TABLE', 'ausleihe_test')
20
 
21
+ # Add this near the top of the file, after other environment variable declarations
22
+ PAGE_TITLE = os.environ.get('PAGE_TITLE', 'Murmel Bibliothek TEST')
23
+
24
  # Create a connection pool
25
  db_config = {
26
  'host': os.environ['MURMEL_DB_HOST'],
 
53
  if 'connection' in locals():
54
  connection.close()
55
 
56
+ templates = Jinja2Templates(directory=".")
57
+
58
  @app.get("/groups")
59
  def get_groups():
60
  sql = "SELECT Gruppe, idGruppe FROM `gruppe` WHERE aktuell is True ORDER BY idGruppe ASC;"
 
153
  return result
154
 
155
  @app.get("/", response_class=HTMLResponse)
156
+ async def read_root(request):
157
+ return templates.TemplateResponse("index.html", {"request": request, "page_title": PAGE_TITLE})
 
 
 
158
 
159
  # run the app
160
  if __name__ == '__main__':