Display Data from Python to HTML

0
7KB

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

Search
Nach Verein filtern
Read More
Social Issues
Die Hard. (1988)
A New York City police officer tries to save his estranged wife and several others taken hostage...
Von Leonard Pokrovski 2023-01-31 14:35:24 0 17KB
История
1917. (2019)
6 апреля 1917 года, разгар Первой мировой войны, Западный фронт на севере Франции. Британский...
Von Nikolai Pokryshkin 2023-02-01 22:53:04 0 31KB
FAQs, Help, and Tutorials
215 Stop Words That Can Cause Your Email to Go to Spam
215 Stop Words That Can Cause Your Email to Go to Spam It is...
Von Leonard Pokrovski 2024-03-26 20:59:12 0 24KB
СМИ
Талант шмеля. The Talent of the Hornet (2020)
Стэф – популярный диджей Радио 105, его изображение висит на одном из небоскрёбов в самом...
Von Nikolai Pokryshkin 2022-09-10 16:29:05 0 22KB
Социальные проблемы
Секреты Лос-Анджелеса. L.A. Confidential. (1997)
Бад Уайт и Эд Эксли работают в полиции Лос-Анджелеса. Они настолько разные, что порой ненавидят...
Von Nikolai Pokryshkin 2023-01-29 11:40:28 0 14KB
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov