Avatar ·

Dynamic data update on the page

📁 method, Advanced Python Topics, Flask microframework, AI, project

There is a simple python flask project running on raspberry. I read temperature and humidity from the sensor, and display them on a bootstrap page. Everything displays fine, but I have to refresh the page to update the data. Tell me how to make temperature and humidity update dynamically?

Python code:

from flask import *from main_my import *app = Flask(__name__)pump_sost = None@app.route('/')@app.route('/<name>')  def main(

                    
                
Avatar ·

Both b'Hello' and b'\\xd0\\x9f\\xd1\\x80...' belong to the same bytes type.

b'Hello' == b'\\x48\\x65\\x6c\\x6c\\x6f'. Bytes that correspond to printable ASCII characters (0x20..0x7e) are by default displayed as those characters in the text representation repr(data) -- the syntax used for bytes constants in Python source code (eval(repr(data)) == data).

Using characters for some bytes instead of hexadecimal codes can be misleading (as in this case). It's easy:

>>> b'Hello'.hex()'48656c6c6f'

Motivation

Log in to leave an answer

Blogs