Kresten
Kresten

Reputation: 838

Interact with python script running infinitive loop from web

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.

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.

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

What would be the better way to do this?

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.

Any hints is appreciated. Best regards Kresten

Upvotes: 0

Views: 240

Answers (2)

sax
sax

Reputation: 3806

not sure about raspberry-pi but I see these solutions:

Upvotes: 0

Benoît Latinier
Benoît Latinier

Reputation: 2108

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.

Upvotes: 1

Related Questions