Display Data from Python to HTML

0
5K

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
Stories
Lawrence of Arabia. (1962)
The story of T.E. Lawrence, the English officer who successfully united and led the diverse,...
Por Leonard Pokrovski 2023-01-16 21:49:58 0 11K
Искусство, культура и развлечения
Последний Вермеер. The Last Vermeer. (2020)
Бывший участник нидерландского движения Сопротивления Джозеф Пиллер расследует дело...
Por Nikolai Pokryshkin 2022-09-25 17:12:33 0 18K
Arts, Culture and Entertainment
Mank (2020)
In 1940, film studio RKO 1940 hires 24-year-old wunderkind Orson Welles under a contract that...
Por Leonard Pokrovski 2022-09-30 20:30:29 0 17K
Social Issues
Babyteeth (2020)
When seriously ill teenager Milla falls madly in love with smalltime drug dealer Moses, it's her...
Por Leonard Pokrovski 2022-10-24 19:23:33 0 16K
Financial Services
Price Ceilings and Price Floors
Key points Price ceilings prevent a price from rising above a certain level....
Por Mark Lorenzo 2023-01-30 14:40:25 0 5K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov