当前位置: 首页>>代码示例>>Python>>正文


Python bottle.template方法代码示例

本文整理汇总了Python中bottle.template方法的典型用法代码示例。如果您正苦于以下问题:Python bottle.template方法的具体用法?Python bottle.template怎么用?Python bottle.template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bottle的用法示例。


在下文中一共展示了bottle.template方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: chart

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def chart(num_bars):
    """Creates a bar chart with the desired number of bars in a chart."""
    if num_bars <= 0:
        num_bars = 1
    data = {"days": [], "bugs": [], "costs": []}
    for i in range(1, num_bars + 1):
        data['days'].append(i)
        data['bugs'].append(random.randint(1,100))
        data['costs'].append(random.uniform(1.00, 1000.00))

    hover = create_hover_tool()
    plot = create_bar_chart(data, "Bugs found per day", "days",
                            "bugs", hover)
    script, div = components(plot)
    return template(TEMPLATE_STRING, bars_count=num_bars,
                      the_div=div, the_script=script) 
开发者ID:fullstackpython,项目名称:blog-code-examples,代码行数:18,代码来源:app.py

示例2: proxy_trough_helper

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def proxy_trough_helper(url):
    print ('PROXY-GET: {0}'.format(url))
    proxy_response = requests.get(url)
    if proxy_response.status_code == 200:
        if proxy_response.headers['Last-Modified']:
            response.set_header('Last-Modified', proxy_response.headers['Last-Modified'])
        if proxy_response.headers['Content-Type']:
            response.set_header('Content-Type',  proxy_response.headers['Content-Type'])
        if proxy_response.headers['Expires']:
            response.set_header('Expires',       proxy_response.headers['Expires'])
        return proxy_response
    else:
        return HTTPResponse(status=proxy_response.status_code,
                            body=template(error_tpl,
                                          headline='Error {0}'.format(proxy_response.status_code),
                                          error='error during proxy call'))




#
# BOTTLE APP
# 
开发者ID:comsysto,项目名称:github-pages-basic-auth-proxy,代码行数:25,代码来源:proxy.py

示例3: play

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def play(code, delay=6, real_delay=0):
  if not validate(code):
    return request_match_page() + template('Invalid code <b>{{code}}</b>', code=code)

  if cull_times() >= MAX_GAMES:
    return request_match_page() + template('Sorry, too many games running')


  command = 'sbatch -t 20:00 -c 2 --mem 1G -x node[001-030]' # --qos tenenbaum'
  command += ' --output slurm_logs/server/%s.out' % code
  command += ' --error slurm_logs/server/%s.err' % code
  command += ' netplay.sh %s %s %s' % (code, delay, real_delay)
  print(command)
  try:
    subprocess.run(command.split())
  except:
    return request_match_page() + template('Unknown error occurred. Make sure your netplay code <b>{{code}}</b> is valid.', code=code)

  start_times.append(time.time())
  return request_match_page() + template('Phillip netplay started with code <b>{{code}}</b>!', code=code) 
开发者ID:vladfi1,项目名称:phillip,代码行数:22,代码来源:phillip.py

示例4: index

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def index():
    
    _,images_list = get_samples()

    page = 1
    if 'p' in request.query:
        page = int(request.query['p'])
        
    subm_data = get_all_submissions()

    vars = {
            'url':url, 
            'acronym':acronym, 
            'title':title,
            'images':images_list,
            'method_params':method_params,
            'page':page,
            'subm_data':subm_data,
            'submit_params':submit_params,
            'instructions':instructions,
            'extension':gt_ext
            }
    return template('index',vars) 
开发者ID:clovaai,项目名称:TedEval,代码行数:25,代码来源:web.py

示例5: icons

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def icons():
    import json
    import bottle

    font = root / 'assets/font'
    sel = (font / 'selection.json').read_text()
    sel = json.loads(sel)
    sel_pretty = json.dumps(sel, indent=2, ensure_ascii=False, sort_keys=True)
    (font / 'selection.json').write_text(sel_pretty)
    icons = [
        (i['properties']['name'], '\\%s' % hex(i['properties']['code'])[2:])
        for i in sel['icons']
    ]
    tpl = str((font / 'icons.less.tpl').resolve())
    txt = bottle.template(
        tpl, icons=icons,
        template_settings={'syntax': '{% %} % {{ }}'}
    )
    f = font / 'icons.less'
    f.write_text(txt)
    print('%s updated' % f) 
开发者ID:naspeh,项目名称:mailur,代码行数:23,代码来源:cli.py

示例6: process_line

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def process_line(cls, line):
        # Format header lines (such that clicking on a column header sorts by
        # that column).
        if re.search(cls.HEADER_LINE_REGEX, line):
            for key, val in cls.SORT_ARGS.items():
                url_link = bottle.template(
                    "<a href='{{ url }}'>{{ key }}</a>",
                    url=cls.get_updated_href(SORT_KEY, val),
                    key=key)
                line = line.replace(key, url_link)
        # Format stat lines (such that clicking on the function name drills into
        # the function call).
        match = re.search(cls.STATS_LINE_REGEX, line)
        if match:
            prefix = match.group(1)
            func_name = match.group(2)
            if func_name not in cls.IGNORE_FUNC_NAMES:
                url_link = bottle.template(
                    "<a href='{{ url }}'>{{ func_name }}</a>",
                    url=cls.get_updated_href(FUNC_NAME_KEY, func_name),
                    func_name=func_name)
                line = bottle.template(
                    "{{ prefix }}({{ !url_link }})\n",
                    prefix=prefix, url_link=url_link)
        return line 
开发者ID:ymichael,项目名称:cprofilev,代码行数:27,代码来源:cprofilev.py

示例7: route_handler

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def route_handler(self):
        self.stats = Stats(self.profile)

        func_name = bottle.request.query.get(FUNC_NAME_KEY) or ''
        sort = bottle.request.query.get(SORT_KEY) or ''

        self.stats.sort(sort)
        callers = self.stats.show_callers(func_name).read() if func_name else ''
        callees = self.stats.show_callees(func_name).read() if func_name else ''
        data = {
            'title': self.title,
            'stats': self.stats.sort(sort).show(func_name).read(),
            'callers': callers,
            'callees': callees,
        }
        return bottle.template(STATS_TEMPLATE, **data) 
开发者ID:ymichael,项目名称:cprofilev,代码行数:18,代码来源:cprofilev.py

示例8: update_config

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def update_config(self, screen=None):

        if screen in self.screens:

            # Build the path to our config file
            conffile = os.path.join(self.folder, "screens", screen, "conf.json")

            # Open the file and load the config
            with open(conffile, "r") as cfg_file:
                params = json.load(cfg_file)

            # We only want the user to edit the "params" section so just
            # retrieve that part
            conf = json.dumps(params.get("params", dict()), indent=4)

            # Build the web page
            return template(SCREEN_CONFIG, screen=screen, conf=conf) 
开发者ID:elParaguayo,项目名称:RPi-InfoScreen-Kivy,代码行数:19,代码来源:webinterface.py

示例9: get_main

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def get_main():
    services = []
    for service in config.sections():
        service_status = get_service_action(service, 'status')
        if service_status['status'] == 'not-found':
            cls = 'active'
        elif service_status['status'] == 'inactive' or service_status['status'] == 'failed':
            cls = 'danger'
        elif service_status['status'] == 'active':
            cls = 'success'
        else:
            cls = 'warning'
        disabled_start = True if cls == 'active' or cls == 'success' else False
        disabled_stop = True if cls == 'active' or cls == 'danger' else False
        disabled_restart = True if cls == 'active' or cls == 'danger' else False
        services.append({'class': cls,
            'disabled_start': disabled_start,
            'disabled_stop': disabled_stop,
            'disabled_restart': disabled_restart,
            'title': config.get(service, 'title'),
            'service': service})
    return template('index', hostname=gethostname(), services=services) 
开发者ID:ogarcia,项目名称:sysdweb,代码行数:24,代码来源:server.py

示例10: new_item

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def new_item():
    global attempts
    # Get the password entered in the password field of the form
    pwd = request.POST.get('password', '').strip()
    # check to see if tehre have been too many failed attemts
    if attempts >= MAX_ATTEMPTS:
        return template('lockout.tpl')
    # unlock the door if the password is correct
    if pwd == PASSWORD:
        attempts = 0
        unlock_door()
        return template('opened.tpl')
    else:
        attempts += 1
        return template('failed.tpl')
        
# Start teh webserver running on port 80 
开发者ID:simonmonk,项目名称:pi_magazine,代码行数:19,代码来源:door_lock_server.py

示例11: cmd_toolkit

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def cmd_toolkit():
    cl_statement = request.forms.get('cl')

    # xmlservice
    itool = iToolKit()
    itransport = iDB2Call()
    itool.add(iCmd5250(cl_statement, cl_statement))
    itool.call(itransport)
   
    # results from list   
    data = ''
    for output_outer in itool.list_out():
        for output_inner in output_outer:
            data += output_inner
    
    return template('cmd', data=data) 
开发者ID:Club-Seiden,项目名称:python-for-IBM-i-examples,代码行数:18,代码来源:sample.py

示例12: send_invite

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def send_invite(self, email, email_template, host):
        entry = self.invites[email]
        if not entry:
            print('No Such Email In Invite List')
            return False

        hash_ = base64.b64encode(os.urandom(21)).decode('utf-8')
        entry['hash_'] = hash_

        full_hash = email + ':' + hash_
        invitekey = base64.b64encode(full_hash.encode('utf-8')).decode('utf-8')

        email_text = template(
            email_template,
            host=host,
            email_addr=email,
            name=entry.get('name', email),
            invite=invitekey,
        )
        self.cork.mailer.send_email(email, 'You are invited to join webrecorder.io beta!', email_text)
        entry['sent'] = str(datetime.utcnow())
        return True 
开发者ID:Rhizome-Conifer,项目名称:conifer,代码行数:24,代码来源:usermanager.py

示例13: main_form

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def main_form():
    """Main page"""
    global saved_profile
    drivers = collection.get_families()

    if not saved_profile:
        saved_profile = request.get_cookie('indiserver_profile') or 'Simulators'

    profiles = db.get_profiles()
    return template(os.path.join(views_path, 'form.tpl'), profiles=profiles,
                    drivers=drivers, saved_profile=saved_profile,
                    hostname=hostname)

###############################################################################
# Profile endpoints
############################################################################### 
开发者ID:knro,项目名称:indiwebmanager,代码行数:18,代码来源:main.py

示例14: platform

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def platform(platform):
    if platform == "flathub":
        return template('flathub', app_list=FLATHUB_HANDLER.get_installed_applications(), isInstalledOverview=True,
                        platform=platform, platformName=PLATFORMS[platform])
    shortcuts = sorted(load_shortcuts(platform), key=lambda s: s['name'])
    data = []
    for shortcut in shortcuts:
        filename = None
        banner = None
        hidden = 'hidden' if 'hidden' in shortcut and shortcut['hidden'] else ''
        if 'banner' in shortcut:
            filename = os.path.basename(shortcut['banner'])
            banner = '/banners/{platform}/{filename}'.format(platform=platform, name=shortcut['name'],
                                                             filename=filename)
        data.append({'hidden': hidden, 'filename': filename, 'banner': banner, 'name': shortcut['name']})

    return template('platform.tpl', shortcuts=data, platform=platform, platformName=PLATFORMS[platform]) 
开发者ID:gamer-os,项目名称:steam-buddy,代码行数:19,代码来源:server.py

示例15: index

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import template [as 别名]
def index():
	return template('main.html') 
开发者ID:simonmonk,项目名称:raspberrypi_cookbook_ed2,代码行数:4,代码来源:web_sensor.py


注:本文中的bottle.template方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。