示例#1
0
文件: weather.py 项目: bmease/weather
def index():
    ''' Index page '''
    print request.remote_addr
    underground = Underground(UNDERGROUND_KEY)

    try:
        conditions = underground.get_feature_by_ip('conditions',
                                                   request.access_route[0]) 
    except QueryNotFoundError:
        if app.debug:
            conditions = underground.get_feature_by_ip('conditions',
                                                       '98.118.119.64') 
        

    return render_template('current-weather.html', conditions=conditions)
示例#2
0
文件: weather.py 项目: bmease/weather
def hourly():
    ''' Hourly weather data '''
    if request.is_xhr:
        full = False
    else:
        full = True

    underground = Underground(UNDERGROUND_KEY)

    try:
        hourly = underground.get_feature_by_ip('hourly',
                                               request.access_route[0]) 
    except QueryNotFoundError:
        if app.debug:
            hourly = underground.get_feature_by_ip('hourly',
                                                   '98.118.119.64') 

    return render_template('hourly-weather.html', full=full, hourly=hourly )