Display Data from Python to HTML

0
7كيلو بايت

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

البحث
الأقسام
إقرأ المزيد
Science Fiction and Fantasy
Logan. (2017)
In a future where mutants are nearly extinct, an elderly and weary Logan leads a quiet life. But...
بواسطة Leonard Pokrovski 2023-04-20 20:33:24 0 16كيلو بايت
Ask an Expert
10 mistakes that will kill your expert video
Many experts make these mistakes and lose their audience. But they are easy to avoid - I have put...
بواسطة FWhoop Xelqua 2022-10-02 12:01:16 0 34كيلو بايت
Научная фантастика и фэнтези
Как приручить дракона. How to Train Your Dragon. (2010)
Вы узнаете историю подростка Иккинга, которому не слишком близки традиции его героического...
بواسطة Nikolai Pokryshkin 2023-04-07 13:57:17 0 23كيلو بايت
Home Automation
Home Automation: Revolutionizing the Way We Live
In recent years, the concept of home automation has moved from a futuristic dream to a...
بواسطة Dacey Rankins 2024-11-08 17:09:38 0 6كيلو بايت
Pesäpallo
Exploring Pesäpallo: Finland's Unique National Sport
Exploring Pesäpallo: Finland's Unique National Sport In the northern reaches of Europe,...
بواسطة Leonard Pokrovski 2024-07-03 22:09:03 0 14كيلو بايت
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov