Display Data from Python to HTML

0
9Кб

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

Поиск
Категории
Больше
Sport
Moneyball. (2011)
Oakland A's general manager Billy Beane's successful attempt to assemble a baseball team on a...
От Leonard Pokrovski 2023-05-11 21:06:03 0 27Кб
Personal Finance
Homeownership and Personal Finance: A Comprehensive Guide to Financial Success
Homeownership is often considered a major milestone in life,...
От Dacey Rankins 2024-12-09 14:27:17 0 6Кб
Internet
How to make Money Online Fast
How to make money quickly on the InternetContentAdvantages and disadvantages of making money on...
От FWhoop Xelqua 2023-05-27 18:59:51 0 22Кб
Arts, Culture and Entertainment
Coco. (2017)
Aspiring musician Miguel, confronted with his family's ancestral ban on music, enters the Land of...
От Leonard Pokrovski 2022-12-30 21:46:57 0 22Кб
Жизненные вопросы
Вверх. Up. (2009)
78-летний ворчун Карл Фредриксен считает, что жизнь обходит его стороной. Чтобы сдержать...
От Nikolai Pokryshkin 2023-01-26 09:12:26 0 28Кб
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov