简体   繁体   English

Python和HTML实时数据

[英]Python and Html real time data

I have a python script which is collecting data that look like this: 我有一个python脚本正在收集看起来像这样的数据:

> Total visitor today: 30
> Current visitors:    5

And I would like to show that data in a small html site in real time. 我想在一个小的html站点中实时显示该数据。 Is there a way to interact this 2 languages? 有没有一种方法可以交互这两种语言? maybe using a small SQLite DB or simply a .txt? 也许使用小型SQLite数据库或仅使用.txt? .csv? .csv? .xml? .xml? how can avoid writing and reading at the same time? 如何避免同时写作和阅读?

I have some limitation in the environment. 我在环境方面有一些限制。 I only have 16Mb to use and I can currently use SQLite, html, JavaScript and basic python. 我只有16Mb的内存,目前可以使用SQLite,html,JavaScript和基本的python。

Thanks. 谢谢。

I would recommend building a basic Flask webapp. 我建议构建一个基本的Flask Webapp。 Not only can you dynamically update your webpage without needing a refresh (check out Flask-Sijax ), it will also host it for you out of the box, meaning you can save yourself the work getting a full web server installed to your limited storage. 您不仅可以动态更新网页而无需刷新(请查看Flask-Sijax ),它还可以为您提供托管服务,这意味着您可以节省将完整的Web服务器安装到有限存储中的工作。 Flask is only 550 kB and is BSD licensed! Flask仅为550 kB,并且已获得BSD许可!

I ended up using a python library for xml writing and reading. 我最终使用python库进行xml读写。 https://docs.python.org/2/library/xml.etree.elementtree.html https://docs.python.org/2/library/xml.etree.elementtree.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM