def _gen_campaign(num_installs, campaign_id, cost):
                # simple multiple of installs
                num_impressions = num_installs*5
                num_clicks = num_installs*2

                agg_data.append({
                    "day"                 : date_str,
                    "app_id"              : app_id,
                    "bundle_id"           : app['bundle_id'],
                    "campaign_id"         : campaign_id,
                    "campaign_name"       : DemoData._get_campaign_name(app_name, campaign_id),
                    "impressions"         : num_impressions,
                    "clicks"              : num_clicks,
                    "downloads"           : num_installs,
                    "spend"               : cost,
                    "currency"            : "USD",
                    "target_manufacturer" : ["Samsung"],
                    "target_platform"     : ["Nexus S", u"\u963f\u91cc\u4e91"],
                    "target_country_code" : ["US"],
                })
def index():
    try:
        # TODO: this may not work
        current_user = request.authorization.username
    except:
        current_user = 'N/A'

    # deauthorzie URL (Link works in Firefox and Chrome. In Opera need to paste in address bar. Not work in IE.)
    parts = list(urlparse.urlsplit(request.url))
    parts[1] = '[email protected]' + parts[1]
    deauthorzie_url = urlparse.urlunsplit(parts)

    today = datetime.datetime.utcnow().date().isoformat()

    agg_url = "/v1/campaign_aggregate?start_day=%s&end_day=%s" % (today, today)
    install_url = "/v1/installs?day=%s" % (today,)

    return render_template('index.html',
        usernames = ', '.join(sorted(DemoData.get_users())),
        current_user = current_user,
        deauthorzie_url = deauthorzie_url,
        agg_url = agg_url,
        install_url = install_url,
    )
    for app_id in app_list:
        app = account.get_app(app_id)
        if not app:
            continue

        # construct some attributes
        app_name = app['application_name']
        device_campaign_lst = account.generate_install_data(day, app_id)

        for did, campaign_id, cost in device_campaign_lst:
            installs.append({
                "device_ids"    : {"udid": did},
                "app_id"        : app_id,
                "bundle_id"     : app['bundle_id'],
                "campaign_id"   : campaign_id,
                "campaign_name" : DemoData._get_campaign_name(app_name, campaign_id),
                "creative"      : "cats.jpg",
                "incentivized"  : 0,
            })

    return _json_response({
        "status": "partial",
        "data": {
            "day": day.isoformat(),
            "installs": installs
        }
    })



if __name__ == '__main__':