Add /city endpoint

This commit is contained in:
Evan 2025-01-22 21:32:12 -05:00
parent 70e5f99832
commit eb57844621

View file

@ -99,6 +99,30 @@ def custom():
return str(resp) 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"]) @app.route("/zipcode", methods=["GET"])
@by_path_counter @by_path_counter
def zipcode(): def zipcode():