Display Data from Python to HTML

0
9KB

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

Rechercher
Catégories
Lire la suite
Научная фантастика и фэнтези
Человек-паук: Через вселенные. Spider-Man: Into the Spider-Verse. (2018)
Мы всё знаем о Питере Паркере. Он спас город, влюбился, а потом спасал город снова и...
Par Nikolai Pokryshkin 2022-12-22 21:20:45 0 16KB
Mental Health
Dyslexia: Prognosis
Dyslexic children require special instruction for word analysis and spelling from an early age....
Par Kelsey Rodriguez 2023-07-05 16:47:11 0 7KB
Financial Services
Market equilibrium, disequilibrium, and changes in equilibrium
In a competitive market, demand for and supply of a good or service determine the...
Par Mark Lorenzo 2023-03-02 21:46:09 0 10KB
Financial Services
How perfectly competitive firms make output decisions
Key points As a perfectly competitive firm produces a greater quantity of output,...
Par Mark Lorenzo 2023-02-21 15:16:17 0 10KB
Искусство, культура и развлечения
Новый кинотеатр «Парадизо». Cinema Paradiso. (1988)
Это рассказ о счастливых днях, когда итальянское кино еще не знало о том, что такое «кризис...
Par Nikolai Pokryshkin 2022-12-09 12:46:05 0 22KB
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov