Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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}
Ejemplo n.º 3
0
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"]}
Ejemplo n.º 4
0
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"])
Ejemplo n.º 5
0
def api_apod_today():
    return jsonify(api_calls.get_nasa_apod(utils.getTodayString()))
Ejemplo n.º 6
0
def api_news():
    return jsonify(api_calls.get_news(utils.getTodayString()))
Ejemplo n.º 7
0
def get_api_today():
    return jsonify(bazaar_api.get_api(utils.getTodayString()))
Ejemplo n.º 8
0
def api_apod_today():
    # return the api of today
    return api_apod(utils.getTodayString())
Ejemplo n.º 9
0
def api_context():
    return jsonify(api_calls.get_topics(utils.getTodayString()))
Ejemplo n.º 10
0
def main_menu_old():
    return render_template("menu.html", today = utils.getTodayString())
Ejemplo n.º 11
0
def main_menu():
    return render_template("index.html", today = utils.getTodayString())
Ejemplo n.º 12
0
def api_covid():
    return jsonify(api_calls.get_covid(utils.getTodayString()))
Ejemplo n.º 13
0
def apod_today():
    # View the Astronomy Picture of the Day: <Today>
    return apod(utils.getTodayString())