Display Data from Python to HTML

0
9K

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': ...})

Căutare
Categorii
Citeste mai mult
Социальные проблемы
Подозрительные лица. The Usual Suspects. (1995)
Если есть преступление, есть и мотив. Если проводится опознание, то по крайней мере есть один...
By Nikolai Pokryshkin 2022-12-01 21:43:39 0 20K
Социальные проблемы
Мясо и кровь. Wildland. (2020)
Ида, после гибели своей матери в автокатастрофе, переезжает жить к своей тёте и двоюродным...
By Nikolai Pokryshkin 2022-10-19 17:58:26 0 21K
Electronics and Electrical
The Electronics Business: Powering the Future of Innovation
The electronics business is one of the most dynamic and fast-growing industries in the world....
By Dacey Rankins 2025-01-21 14:41:03 0 6K
Life Issues
Nymphomaniac: Teil 2. (2013)
A self-diagnosed nymphomaniac recounts her erotic experiences to the man who saved her after a...
By Leonard Pokrovski 2023-05-02 20:33:32 0 18K
История
Унесённые ветром. Gone with the Wind. (1939)
Могучие ветры Гражданской войны в один миг уносят беззаботную юность южанки Скарлетт О`Хара,...
By Nikolai Pokryshkin 2023-03-03 15:06:58 0 15K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov