示例#1
0
 def decorator(func):
     subdomains = [(None, '')]
     if app.config.get('DEFAULT_SUBDOMAIN'):
         subdomains.append((app.config.get('DEFAULT_SUBDOMAIN'), '_default'))
     if app.config.get('SECURE_SUBDOMAIN'):
         if secure == 'both':
             subdomains.append((app.config.get('SECURE_SUBDOMAIN'), '_secure'))
         elif secure:
             subdomains = [(app.config.get('SECURE_SUBDOMAIN'), '')]
     for subdomain, suffix in subdomains:
         name = func.func_name + suffix
         app.add_url_rule(url, name, cache_for(cache_age, cache_private)(render(template)(func)),
                          methods=methods, subdomain=subdomain)
     return func
示例#2
0

@expose_web('/welcome_email', cache_age=3600)
def welcome_email():
    from rockpack.mainsite.core.email import env
    return env.get_template('welcome.html').render(web=True)


@expose_web('/', 'web/home.html', cache_age=3600)
def homepage():
    api_urls = json.dumps(ws_request('/ws/'))
    channels = ws_request('/ws/channels/', size=8)
    return dict(api_urls=api_urls, injectorUrl=url_for('injector'), top_channels=channels)

if app.config.get('SECURE_SUBDOMAIN'):
    app.add_url_rule('/', 'secure_home_redirect',
                     lambda: redirect(url_for('homepage')), subdomain=app.config['SECURE_SUBDOMAIN'])

if app.config.get('ADMIN_SUBDOMAIN'):
    app.add_url_rule('/', 'admin_redirect',
                     lambda: redirect('/admin/'), subdomain=app.config['ADMIN_SUBDOMAIN'])


@expose_web('/wonder-discover', 'web/home.html', cache_age=3600)
def wonder_discover():
    return dict()


@expose_web('/fullweb', 'web/fullweb.html', cache_age=3600)
def fullweb():
    if app.config.get('ENABLE_FULLWEB', False):
        api_urls = json.dumps(ws_request('/ws/'))