Display Data from Python to HTML
Postado 2023-01-26 19:18:03
0
13KB
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
- Recreation
- Reference
- Regional
- Science
- Shopping
- Society
- Sports
- Бизнес
- Деньги
- Дом
- Досуг
- Здоровье
- Игры
- Искусство
- Источники информации
- Компьютеры
- Наука
- Новости и СМИ
- Общество
- Покупки
- Спорт
- Страны и регионы
- World
Leia mais
Exploring Pesäpallo: Finland's Unique National Sport
Exploring Pesäpallo: Finland's Unique National Sport
In the northern reaches of Europe,...
Is Influence the Same as Persuasion?
A Deep, Detailed Exploration of How These Two Concepts Differ — and Why It Matters...
Exploring the Evolution of News Consumption: Magazines and E-zines
In an age of rapid digital transformation, the way we consume news has undergone a significant...
What Challenges Do Creators Face?
The Creator Economy has opened up countless opportunities for individuals to share their...
Dial M for Murder. (1954)
A former tennis star arranges the murder of his adulterous wife.
My Link