Display Data from Python to HTML

0
12KB

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

Pesquisar
Categorias
Leia mais
Научная фантастика и фэнтези
Ая и ведьма. Earwig and the Witch. (2021)
Несмотря на то что 10-летняя Ая не знает родительской ласки и воспитывается в детском приюте...
Por Nikolai Pokryshkin 2022-09-21 19:57:32 0 35KB
Социальные проблемы
Расёмон. Rashomon. (1950)
Древняя Япония. В лесу изнасилована женщина, а её муж убит. Есть четыре точки зрения на это...
Por Nikolai Pokryshkin 2023-02-25 13:44:25 0 19KB
Научная фантастика и фэнтези
Мстители: Финал. Avengers: Endgame. (2019)
Оставшиеся в живых члены команды Мстителей и их союзники должны разработать новый план, который...
Por Nikolai Pokryshkin 2023-01-02 11:33:57 0 27KB
Business
How Do I Determine If I Am Capable of Starting a Business?
Starting a business is a bold and exciting venture, but it’s not without its challenges....
Por Dacey Rankins 2025-02-28 16:10:37 0 9KB
Financial Services
Explicit and implicit costs and accounting and economic profit
Key points Privately owned firms are motivated to earn profits. Profit is the...
Por Mark Lorenzo 2023-04-24 18:42:05 0 13KB

BigMoney.VIP Powered by Hosting Pokrov