def get_film(message, uid):
    result, ok = db.get_user_info(uid)
    if not ok:
        return {"answer": "",
                "status": 50}
    city = result[2]
    _, ok, pogoda = api.weather(city)
    if not ok:
        return {"answer": "",
                "status": 11}
    return {"answer": answers[50]+utils.do_film_advise(pogoda),
            "status": 200}
def advise(message, uid):
    result, ok = db.get_user_info(uid)
    if not ok:
        return {"answer": "",
                "status": 30}
    city = result[2]
    _, ok, pogoda = api.weather(city)
    if not ok:
        return {"answer": "",
                "status": 11}
    return {"answer": utils.do_pogoda_advise(pogoda),
            "status": 200}
def notify(now):
    users, ok = db.get_users_by_time(now)
    if ok:
        notifications = []
        for user in users:
            info, ok, pogoda = api.weather(user["city"])
            if not ok:
                notifications.append({"answer": "",
                                      "uid": user["uid"],
                                      "status": 40})
            else:
                notifications.append({"answer": utils.collect_notification(info, pogoda, user["name"]),
                                      "uid": user["uid"],
                                      "status": 200})
        return notifications
    return []
示例#4
0
def weather():
    if request.method == "POST":
        if len(request.form['address']) > 0:
            weather_data = api.weather(str(request.form['address']).strip())
            if len(weather_data) > 0:
                return render_template('weather_result.html',
                                       address=str(
                                           request.form['address']).strip(),
                                       weather=weather_data,
                                       error="null")
            else:
                return render_template('weather_result.html',
                                       error="Please input a valid address.")
        else:
            return render_template('weather.html')
    else:
        return render_template('weather.html')
def weather(message, uid):
    query = message.split(" ", 1)
    if len(query) < 2:
        result, ok = db.get_user_info(uid)
        if not ok:
            return {"answer": "",
                    "status": 10}
        else:
            city = result[2]
    else:
        city = query[1]
    answer, ok, _ = api.weather(city)
    if ok:
        return {"answer": answer,
                "status": 200}
    else:
        return {"answer": "",
                "status": 11}
示例#6
0
def index():
        '''
        Routes the home page

        return template html dummy
        '''
        if request.method == 'POST':
                global zipc
                zipc = request.form['zipcode']
                global genre
                genre = request.form['genre']
                global rating
                rating = request.form['rating']
                global temp
                temp = api.weather(zipc)
                if temp == -1000:
                        return render_template("dummy.html")
                elif temp >= thresh:
                        return redirect("/nochill")
                else:
                        return redirect("/chill")
        d = datetime.datetime.now()
        date = d.strftime('%m-%d-%Y')
        return render_template("dummy.html",date=date)