Display Data from Python to HTML
Postado 2023-01-26 19:18:03
0
15K
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
- Arts
- Business
- Computers
- Jogos
- Health
- Início
- Kids and Teens
- Money
- News
- Personal Development
- Recreation
- Regional
- Reference
- Science
- Shopping
- Society
- Sports
- Бизнес
- Деньги
- Дом
- Досуг
- Здоровье
- Игры
- Искусство
- Источники информации
- Компьютеры
- Личное развитие
- Наука
- Новости и СМИ
- Общество
- Покупки
- Спорт
- Страны и регионы
- World
Leia Mais
How to prioritize multiple goals?
The Tyranny of "And"
We are living in a state of perpetual expansion. We want to be the...
How Do I Align Marketing With Sales and Understand the Buyer’s Journey?
In B2B organizations, marketing and sales often operate like neighbors who rarely talk: close in...
What Are Common Mistakes When Using User Stories?
User stories are one of the most widely adopted tools in Agile product development. They provide...
Old (2021)
A vacationing family discovers that the secluded beach where they're relaxing for a few hours is...
Build a 2D game with Python
Python is an outstanding language for people learning to program, and perfect for anyone...