def api(zip_code): if not zip_codes.is_listed(zip_code): return json.dumps({"error":"Couldn't find zip code "+zip_code})+"\n",404 city = " / ".join(zip_codes.city(zip_code)) txt = weather.forecast_txt(zip_code) alerts,forecast,meta = weather.parse(txt) print(forecast) return jsonify( city=city, alerts=alerts, forecast=[(day, "\u2014".join(text)) for day, text in forecast], meta=meta )
def curl(zip_code): if not zip_codes.is_listed(zip_code): return "Hm, I don't have zip code " + zip_code + "\n",404 city = " / ".join(zip_codes.city(zip_code)) txt = weather.forecast_txt(zip_code) alerts,forecast,meta = weather.parse(txt) print(forecast) return render_template( "forecast.txt", city=city, alerts=alerts, forecast=forecast, meta=meta )
def forecast(zip_code): if not zip_codes.is_listed(zip_code): return render_template("wrong_zip.html", zip_code=zip_code),404 city = " / ".join(zip_codes.city(zip_code)) txt = weather.forecast_txt(zip_code) alerts,forecast,meta = weather.parse(txt) print(forecast) return render_template( "forecast.html", city=city, alerts=alerts, forecast=forecast, meta=meta )
def test_city_55057(): assert z.city('55057') == ['northfield']
def test_city_90210(): assert z.city('90210') == ['beverly hills']
def test_city_20815(): assert z.city('20815') == ['chevy chase']