[nominatim-web] Handle missing accept-language



commit 9ec6f2bb0ec6fb3be2f40e8d2ab940757fb5f1bf
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date:   Fri Apr 2 15:04:01 2021 +0200

    Handle missing accept-language

 app/main.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/app/main.py b/app/main.py
index faf44a8..536e4b0 100644
--- a/app/main.py
+++ b/app/main.py
@@ -48,8 +48,8 @@ def healthcheck():
 
 @app.get("/search")
 def search(request: Request):
-    lang = request.query_params["accept-language"]
-    limit = request.query_params["limit"]
+    lang = request.query_params.get("accept-language", "none")
+    limit = request.query_params.get("limit", "none")
     country = request.query_params.get("country", "none")
     state = request.query_params.get("state", "none")
     city = request.query_params.get("city", "none")
@@ -100,7 +100,7 @@ def search(request: Request):
 def reverse(request: Request):
     lat = "{:.5f}".format(float(request.query_params["lat"]))
     lon = "{:.5f}".format(float(request.query_params["lon"]))
-    lang = request.query_params["accept-language"]
+    lang = request.query_params.get("accept-language", "none")
 
     key = f"rev:{lang}:{lat}x{lon}"
     if resp := redis_conn.get(key):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]