Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从文件中读取新数据并将其显示在html页面上_Python_Python 3.x - Fatal编程技术网

Python 从文件中读取新数据并将其显示在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

在我的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"></center>
<center><h2>%s</h2></center>
</body>
</html>
""" %(temperature)
f=open(“demofile.txt”、“r”)
温度=f.读数()
f、 关闭()
打印(温度)
第“”页\
%
“”“%(温度)
我的问题是,文件每10分钟更新一次-我如何在每次访问html页面时重新加载或从文件中提取新内容

因为我正在流式传输视频,所以脚本一直在运行,所以我无法停止它并再次运行它以从文件中获取最新的数据


请告知

当有人访问页面时,请在呈现页面之前更新文件,然后呈现它。我想你需要一个Web服务器,比如flask/django?