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
What Is Retargeting? A Complete Guide to Re-Engaging Website Visitors and Lost Prospects
Most people who visit a website do not take action the first time.
They browse, compare, get...
What are the best life hacks for saving time?
What Are the Best Life Hacks for Saving Time?
Time is one of the few truly non-renewable...
What is the difference between personal growth and personal development?
What Is the Difference Between Personal Growth and Personal Development?
The terms personal...
What Is the Personal Life Story of Famous Advertisers?
Advertising history is often told through campaigns, agencies, and awards, but behind every...
How Can I Reduce YouTube Advertising Costs?
Advertising on YouTube can be highly effective—but without proper strategy, costs can...