2

I'm trying to create a control system that will run on a Raspberry PI configured as a server. I'll have a python program running on the server that will control a process (i.e. temperature).

My question is how would I go about communicating the the running python program via a web browser? I'd like to be able to set a control point and get back the current process value.

I'm new to web development and have been looking at PHP and CGI, but that doesn't feel right to me. Someone also suggested communicating via SQL, where a script and the python program would both have access, but this doesn't feel right either?

What is the preferred method for doing this?

Thanks

sshashank124
  • 31,495
  • 9
  • 67
  • 76

1 Answers1

2

The easiest thing would be install Flask:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def main():
    return "Hey cool, it works!"

if __name__ == "__main__":
    app.run("0.0.0.0", port=80, debug=True) # Might have to run as sudo for port 80
Wayne Werner
  • 49,299
  • 29
  • 200
  • 290