Display Data from Python to HTML

0
13K

When making a web application, you're probably thinking if displaying data from Python to HTML is possible. The good news is that it is possible! The only library required for Python is called Jinja2. With Jinja2, you can render HTML files and place key values in the file. Here's an example:

templates/index.html:
<div class="container" id="container" style="text-align: center;color: white;">    {% if get_count %}
        <input type="checkbox" id="toggle-button" class="toggle-button" checked>
    {% else %}
        <input type="checkbox" id="toggle-button" class="toggle-button">
    {% endif %}

</div>

main.py:

@app.route('/')

async def main_page(request):

    return await render('moderation.html', context={'get_count': ...})

Pesquisar
Categorias
Leia Mais
Business
Email Marketing: How to Increase Sales with Email
Email Marketing: How to Increase Sales with Email Email marketing remains one of the most...
Por Dacey Rankins 2024-09-04 15:26:17 0 13K
Business
Labor market analytics: what is it?
Sometimes we use the same words with the interlocutor, but at the same time we talk about...
Por Dacey Rankins 2024-09-04 16:43:40 0 12K
Социальные проблемы
Как быть хорошей женой. How to Be a Good Wife. (2020)
Хранить очаг и не мешкая исполнять супружеский долг: так учит Полетт Ван дер Бек в своей домашней...
Por Nikolai Pokryshkin 2022-10-23 16:26:44 0 30K
Social Issues
Capturing the Friedmans (2003)
Documentary on the Friedmans, a seemingly typical, upper-middle-class Jewish family whose world...
Por Leonard Pokrovski 2023-07-31 20:28:12 0 532K
История
Однажды на Диком Западе. Once Upon a Time in the West (1968)
Молодая вдова отказывается продать ферму дельцу, задумавшему проложить по этой земле железную...
Por Nikolai Pokryshkin 2022-12-07 19:10:08 0 30K

BigMoney.VIP Powered by Hosting Pokrov