Add /city endpoint
This commit is contained in:
parent
70e5f99832
commit
eb57844621
1 changed files with 24 additions and 0 deletions
|
@ -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():
|
||||
|
|
Loading…
Reference in a new issue