与从Web运行不定式循环的python脚本交互 [英] Interact with python script running infinitive loop from web

查看:178
本文介绍了与从Web运行不定式循环的python脚本交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的raspberry-pi上有一个python脚本(每5秒钟)运行一个循环,用GPIO通过一些电子设备来控制锅的温度。

I have a python script on my raspberry-pi continuously (every 5 seconds) running a loop to control the temperature of a pot with some electronics through GPIO.

我通过让python脚本将温度写入我从java脚本和网页上的HTTP请求的文本文件来监控网页上的温度。

I monitor temperature on a web page by having the python script write the temperature to a text file witch I request from java script and HTTP on a web page.

我想将参数传递给python脚本以对控件进行更改,例如更改目标温度。

I would like to pass a parameter to the python script to make changes to the controlling, like change the target temperature.

最好的方法是什么?

我正在研究一个解决方案,其中python脚本在文本文件中查找参数,然后让第二个python脚本写入对此文件的更改。第二个python脚本将由来自网页的http请求运行。

I'm working on a solution, where the python script is looking for parameters in a text file and then have a second python script write changes to this file. This second python script would be run by a http request from the web page.

这是一种方法吗?或者我错过了一种更直接的方法来做到这一点。

Is this a way to go? Or am I missing a more direct way to do this.

这必须在很多时候完成并在网上描述,但我一无所获。也许我没有正确的术语来描述问题。

This must be done many time before and described on the web, but I find nothing. Maybe I don't have the right terms to describe the problem.

任何提示都表示赞赏。
祝你好运Kresten

Any hints is appreciated. Best regards Kresten

推荐答案

你必须在某处编写循环脚本的配置。所以文件或数据库是可能的选择,但我会说如果你有一些参数,那么格式化的文件(ini,yaml,...)就是你的选择。

You have to write somewhere your configuration for looping script. So file or database are possible choices but I would say that a formatted file (ini, yaml, …) is the way to go if you have a little number of parameters.

这篇关于与从Web运行不定式循环的python脚本交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆