0
I have the following app:
#!/usr/bin/python3
from bottle import template, route, run
import html
cabeca = ('''
<html lang="pt-br">
<head>
</head>
<body>
<nav id="menu">
{{menu}}
</nav>
<main id="conteudo">
{{conteudo}}
</main>
</body>
</html>
''')
menu = (('add', 'flaticon-add', 'Adicionar'),
('busca', 'flaticon-target', 'Buscar'),
('balanco', 'flaticon-coin', 'Balanço'),
('conf', 'flaticon-settings', 'Configurações'))
def cria_menu():
bloco = ('<nav id="menu">')
for item in menu:
bloco += ('<div class="menu-item">\
<a class="menu-link" href="{}">\
<img class="{} menu-icon" alt="{}"/>\
</a>\
</div>\
'.format(item[0], item[1], item[2]))
bloco += ('</nav>')
return(bloco)
@route('/')
def index():
return(template(cabeca, menu = html.unescape(cria_menu())\
.replace('<', '<')\
.replace('>', '>')\
.replace('"', '"'), conteudo = 'Alguma coisa'))
run(port = 8000, debug = True, reloader = True)
No matter what I do, I can’t render the page.
Returns an error ? It is important to add information to help resolve your problem or question. You can do this editing your question.
– NoobSaibot
As already mentioned, it would be of utmost importance to provide error output, debugging you can see this. I ran your file on Python3 and making explicit the import of
unescape
:from html import unescape
and returned me a text output with the html mounted.– Tuxpilgrim