Add /zipcode
This commit is contained in:
parent
9e4c4ef5cf
commit
64d8a8eb1a
2 changed files with 19 additions and 2 deletions
|
@ -99,7 +99,21 @@ def custom():
|
||||||
return str(resp)
|
return str(resp)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/test", methods=["GET", "POST"])
|
@app.route("/zipcode", methods=["GET"])
|
||||||
|
@by_path_counter
|
||||||
|
def zipcode():
|
||||||
|
if "zipcode" in request.values:
|
||||||
|
zipcode = request.values["zipcode"]
|
||||||
|
|
||||||
|
if len(zipcode) == 5:
|
||||||
|
weather = _get_weather(_get_cords(zipcode))
|
||||||
|
return strq(weather)
|
||||||
|
else:
|
||||||
|
return strq("Sorry, I don't understand that zipcode.")
|
||||||
|
else:
|
||||||
|
return strq("A zipcode is required.")
|
||||||
|
|
||||||
|
@app.route("/test", methods=["GET"])
|
||||||
@by_path_counter
|
@by_path_counter
|
||||||
def test():
|
def test():
|
||||||
return "\"Successful test. By the way, do you know the muffin man? The muffin man? The muffin man? Do you know the muffin man? He doesn't exist.\""
|
return strq("Successful test. By the way, do you know the muffin man? The muffin man? The muffin man? Do you know the muffin man? He doesn't exist.")
|
||||||
|
|
|
@ -51,6 +51,9 @@ def validate_data_presence(data: t.Dict[str, t.Any], keys: list[str]) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def strq(str: str) -> str:
|
||||||
|
return "\"" + str + "\""
|
||||||
|
|
||||||
def _get_weather(lat, long):
|
def _get_weather(lat, long):
|
||||||
try:
|
try:
|
||||||
if lat is None or long is None:
|
if lat is None or long is None:
|
||||||
|
|
Loading…
Reference in a new issue