Reputation: 554
I'm receiving data from an Arduino,parsing it using Python and my intent is to update the values in the HTML using the data from serial. Like <h6>value</h6>
so the new value will be there when I refresh the page. How to do it?
Upvotes: 0
Views: 1559
Reputation: 137
I'm not sure about your situation but, We use python as the server-side language and for making a dynamic HTML, we use Django Template which is developed for Django (A python based framework). Here's an example of making a simple html with some data:
<!DOCTYPE html>
<html>
<head>
<meta name="keywords" content="{{ meta.keywords }}" />
<meta name="robots" content="index,follow" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="HandheldFriendly" content="true"/>
<title>{{ meta.title}}</title>
<meta name="description" content="{{ meta.description }}">
<meta name="og:description" content="{{ meta.description }}">
<meta property="og:title" content="{{ meta.title }}" />
<meta property="og:image" content="{{ meta.image_url}}" />
<meta property="og:image:type" content="image/png" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" charset="utf-8">
</head>
<body>
<h1>{{ data.title }}</h1>
<h2>{{ data.description }}</h2>
{% if data.additional_info %}
<p>
{{ data.additional_info }}
</p>
{% endif %}
{% if data.list1|length > 0 %}
{% for item in data.list1 %}
<h2>{{ item.title }}</h2>
<p>
{{ item.content }}
</p>
{% endfor %}
{% endif %}
{% if data.list2|length > 0 %}
{% for item in data.list2 %}
<h2>{{ item.title }}</h2>
<p>
{{ item.content }}
</p>
{% endfor %}
{% endif %}
{% if data.list3|length > 0 %}
{% for item in data.list3 %}
<h2>{{ item.title }}</h2>
<p>
{{ item.content }}
</p>
{% endfor %}
{% endif %}
</body>
</html>
Upvotes: 1