Display Data from Python to HTML

0
6K

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
Categories
Read More
Социальные проблемы
Город Бога. City of God. (2002)
Парень по кличке Ракета, балансирующий между честной жизнью и мелкими правонарушениями, и его...
By Nikolai Pokryshkin 2022-11-18 16:41:21 0 23K
Жизненные вопросы
Гран Торино. Gran Torino. (2008)
Вышедший на пенсию автомеханик Уолт Ковальски проводит дни, починяя что-то по дому, попивая пиво...
By Nikolai Pokryshkin 2023-03-13 18:57:52 0 18K
Financial Services
Decisions with a budged constraint
Key points The budget constraint is the boundary of...
By Mark Lorenzo 2023-02-13 15:15:43 0 7K
Animal
"Veterinary medicine is exciting!"
"Veterinary medicine is exciting!" Veterinary medicine is a field of scientific knowledge and...
By Leonard Pokrovski 2024-04-10 21:53:12 0 9K
Financial Services
Beyond GDP: other ways to measure the economy
Key points Gross national product, or GNP, includes what is produced...
By Mark Lorenzo 2023-03-03 19:43:30 0 10K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov