def get_covid(date): desiredDate = datetime.strptime(date, '%Y-%m-%d') #print(desiredDate) if desiredDate < datetime(2020, 4, 14): desiredDate = '2020-04-14' elif desiredDate >= datetime.strptime(utils.getTodayString(), '%Y-%m-%d'): desiredDate = (datetime.strptime(utils.getTodayString(), '%Y-%m-%d') - timedelta(days=2)).strftime('%Y-%m-%d') else: desiredDate = desiredDate.strftime('%Y-%m-%d') return covid.getGlobalAndTurkeysDataByDate(desiredDate)
def favorites_post(input): if not input: input = utils.getTodayString() if input in favorites: return{ "Duplicate error" : "Date \"" + input + "\" already Favorite" } else: favorites.append(input) return {"POST succesful": favorites}
def get_weather_today(): if utils.checkInputFormat(date): if utils.checkDate(date) == "valid": g = geocoder.ip('me') location = g.latlng today = utils.getTodayString() url = "https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/weatherdata/history?&aggregateHours=24&startDateTime=" + today + "T00:00:00&endDateTime=" + today + "T23:59:59&unitGroup=us&contentType=json&dayStartTime=0:0:00&dayEndTime=0:0:00&location=" + str( location[0]) + "," + str( location[1]) + "&key=7ITZ7NZ04VSIKZBKADNHGZ1UJ" return requests.get(url).json() else: return {"articles": ["Please give a valid date."]} else: return {"articles": ["Wrong input format"]}
def apod_today(): apodJson = api_calls.get_nasa_apod(utils.getTodayString()) if "hdurl" in apodJson: url = apodJson["hdurl"] return render_template("apod.html", url=apodJson["url"])
def api_apod_today(): return jsonify(api_calls.get_nasa_apod(utils.getTodayString()))
def api_news(): return jsonify(api_calls.get_news(utils.getTodayString()))
def get_api_today(): return jsonify(bazaar_api.get_api(utils.getTodayString()))
def api_apod_today(): # return the api of today return api_apod(utils.getTodayString())
def api_context(): return jsonify(api_calls.get_topics(utils.getTodayString()))
def main_menu_old(): return render_template("menu.html", today = utils.getTodayString())
def main_menu(): return render_template("index.html", today = utils.getTodayString())
def api_covid(): return jsonify(api_calls.get_covid(utils.getTodayString()))
def apod_today(): # View the Astronomy Picture of the Day: <Today> return apod(utils.getTodayString())