def index():
    """Main entry point to the webapp."""
    last = request.cookies.get('last')

    if last is not None:
        lastAction = last.split(',')
        print lastAction

        if lastAction[0] == 'recap':
            response = present.provide_dropdowns(recapDefault=lastAction[1])
        elif lastAction[0] == 'fcast':
            response = present.provide_dropdowns(fcastDefault=lastAction[1])
    else:
        response = present.provide_dropdowns()

    print response
    print last
    return response
def previous_forecasts():
    """Show previous forecasts in 'flash' area."""
    location = request.args.get('fcast_location')
    if location is not None:
        fcast = dbutil.old_forecasts(location)
        fcastStr = present.format_forecasts(fcast)
        flash(fcastStr)

    response = present.provide_dropdowns(fcastDefault=location)
    response.set_cookie('last', 'fcast,' + location)
    return response
def recap():
    """Show previous days' values in 'flash' area."""
    location = request.args.get('location')
    if location is not None:
        prev = dbutil.previous_days(location)
        prevStr = present.format_previous(prev)
        flash(prevStr)

    response = present.provide_dropdowns(recapDefault=location)
    response.set_cookie('last', ('recap,' + location))
    return response