From eb5784462176ac800796bbfb761e2636bb1cc513 Mon Sep 17 00:00:00 2001 From: Evan <17254809+bigun27@users.noreply.github.com> Date: Wed, 22 Jan 2025 21:32:12 -0500 Subject: [PATCH] Add /city endpoint --- app/routes/client.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/routes/client.py b/app/routes/client.py index b5c3573..0f6598a 100644 --- a/app/routes/client.py +++ b/app/routes/client.py @@ -99,6 +99,30 @@ def custom(): return str(resp) +@app.route("/city", methods=["GET"]) +@by_path_counter +def city(): + if "city" in request.values: + city = request.values["city"] + # Return a different message depending on the caller's choice + # Asheboro + if city == "1": + weather = _get_weather(35.6396, -79.8509) + return strq(weather) + # Lynchburg + elif city == "2": + weather = _get_weather(37.3490, -79.1787) + return strq(weather) + # Cullowhee + elif city == "3": + weather = _get_weather(35.3087, -83.1861) + return strq(weather) + else: + return strq("Your selection is invalid.") + else: + return strq("A city is required.") + + @app.route("/zipcode", methods=["GET"]) @by_path_counter def zipcode():