Python 从文件中读取新数据并将其显示在html页面上
在我的Raspberry Pi上,我构建了一个脚本,可以从文件中读取数据并显示实时视频流 然后,内容将显示在html页面上:Python 从文件中读取新数据并将其显示在html页面上,python,python-3.x,Python,Python 3.x,在我的Raspberry Pi上,我构建了一个脚本,可以从文件中读取数据并显示实时视频流 然后,内容将显示在html页面上: f = open("demofile.txt", "r") temperature=f.read() f.close() print(temperature) PAGE="""\ <html> <body> <center><img src="stream.mjpeg" width="640" height="480">&l
f = open("demofile.txt", "r")
temperature=f.read()
f.close()
print(temperature)
PAGE="""\
<html>
<body>
<center><img src="stream.mjpeg" width="640" height="480"></center>
<center><h2>%s</h2></center>
</body>
</html>
""" %(temperature)
f=open(“demofile.txt”、“r”)
温度=f.读数()
f、 关闭()
打印(温度)
第“”页\
%
“”“%(温度)
我的问题是,文件每10分钟更新一次-我如何在每次访问html页面时重新加载或从文件中提取新内容
因为我正在流式传输视频,所以脚本一直在运行,所以我无法停止它并再次运行它以从文件中获取最新的数据
请告知当有人访问页面时,请在呈现页面之前更新文件,然后呈现它。我想你需要一个Web服务器,比如flask/django?