How to use the bottle.template function in bottle

To help you get started, we’ve selected a few bottle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vimeo / graph-explorer / graph_explorer / app.py View on Github external
'len_graphs_all': len(graphs_all),
             'len_targets_matching': len(targets_matching),
             'len_graphs_matching': len(graphs_matching),
             }
    out = ''
    graphs = []
    targets_list = {}
    # the code to handle different statements, and the view
    # templates could be a bit prettier, but for now it'll do.
    if query['statement'] in ('graph', 'lines', 'stack'):
        graphs_targets_matching = g.build_from_targets(targets_matching, query, preferences)[0]
        stats['len_graphs_targets_matching'] = len(graphs_targets_matching)
        graphs_matching.update(graphs_targets_matching)
        stats['len_graphs_matching_all'] = len(graphs_matching)
        if len(graphs_matching) > 0 and deps:
            out += template('templates/snippet.graph-deps')
        for key in sorted(graphs_matching.iterkeys()):
            graphs.append((key, graphs_matching[key]))
    elif query['statement'] == 'list':
        # for now, only supports targets, not graphs
        targets_list = targets_matching
        stats['len_graphs_targets_matching'] = 0
        stats['len_graphs_matching_all'] = 0

    args = {'errors': errors,
            'query': query,
            'graphs': graphs,
            'targets_list': targets_list,
            'tags': tags,
            }
    args.update(stats)
    if minimal:
github morganbengtsson / microreader / microreader.py View on Github external
def import_channels():
    return template('import')
github herreraemanuel / mia / mia.py View on Github external
def read_folder(path):
    to_html = []
    if path == '':
        path_dir = path_local
    else:
        path_dir = path_local + '/' + path

    try:
        file_list = os.listdir(path_dir)
    except Exception:
        return template(PAGE, error="Folder/Directory not found, Please check the name", path_dir=path)
    for archivo in file_list:
        if archivo == 'mia_main.py' or archivo == 'bottle.py' or archivo == 'bottle.pyc':
            pass
        else:
            file_path = os.path.join(path_dir, archivo)
            if os.path.isdir(file_path) == True:
                cosa = HtmlFile('folder', request.fullpath, archivo, file_path)
                to_html.append(cosa)
            else:
                extension = os.path.splitext(archivo)[1].replace('.', '')
                if extension in TEXT_TYPE:
                    type_file = 'text'
                elif extension in AUDIO_TYPE:
                    type_file = 'audio'
                elif extension in IMAGE_TYPE:
                    type_file = 'imagen'
github LeeMendelowitz / DCMetroMetrics / dcmetrometrics / web / WebPageGenerator.py View on Github external
def makePage(*args, **kwargs):
    curTime = toLocalTime(utcnow())
    kwargs['curTime'] = curTime
    return bottle.template(*args, **kwargs)
github ampotos / dynStruct / _dynStruct / web_ui.py View on Github external
def block_view():
    block_id = check_block_id(bottle.request.query.id)

    if block_id or block_id == 0:
        return bottle.template("block_view", block=_dynStruct.l_block[block_id])
    else:
        return bottle.template("error", msg="Bad block id")
github ampotos / dynStruct / _dynStruct / web_ui.py View on Github external
def block_search():
    id_struct = check_struct_id(bottle.request.query.id_struct)

    if id_struct == False:
            return bottle.template("error", msg="Bad struct id")
    else:
        return bottle.template("block_search", id_struct=id_struct)
github vimeo / graph-explorer / graph_explorer / app.py View on Github external
def handle_graphs_minimal(query, deps):
    '''
    like handle_graphs(), but without extra decoration, so can be used on
    dashboards
    TODO dashboard should show any errors
    '''
    if not query:
        return template('templates/graphs', query=query, errors=errors)
    return render_graphs(query, minimal=True, deps=deps)
github mushorg / modbus-tk / hmi / master_webhmi.py View on Github external
TEMPLATES.clear()
    master = APP.get_master(master_id)
    requests = APP._db.get_hr_requests_for_slave(master_id, slave_id)
    name = 'Slave {0} - Function {1}'.format(slave_id, 3)
    friendly_name = 'Slave {0} - Function {1} - All Registers'.format(slave_id, 3)
    url = "/modbus-read-all-hr/{0}/{1}".format(master_id, slave_id)
    all_results = {}
    try:
        for req in requests:
            i = int(req['address'])
            #print "%s, %s, %s"%(int(slave_id), int(req['address']), int(req['length']))
            results = master.modbus.execute(int(slave_id), int(3), int(req['address']), int(req['length']))
            for result in results:
                all_results[i] = {'result': result, 'register_hex': hex(i)}
                i += 1
        return template('templates/master_results_all_hr', results=all_results, url=url,
                name=name, master=master, friendly_name=friendly_name)
    except modbus.ModbusError, msg:
        return template('templates/modbus_error', msg=msg, name=name, url=url, master=master, friendly_name=friendly_name)
github comsysto / github-pages-basic-auth-proxy / cs_proxy / proxy.py View on Github external
def error500(error):
        return template(error_tpl, headline='Error '+error.status, error=error.body)
github comsysto / github-pages-basic-auth-proxy / cs_proxy / proxy.py View on Github external
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'))