I have a project that I am putting together it is working well so far.
But I am a bit lost on where to start python wise. The basics of the projects are A lighting system that is controlled by an Arduino over a wireless link (Already setup) that receives commands from a python program through serial over a xBee network (This part is coded and working). I want the project controllable over the internet.
I was thinking about running it so that the python program runs an http server which is fairly easy to setup.
Here is where I am having trouble as I have not played with python in the past. How do I get the program to respond to request and run code depending on what was clicked on the page?
Can anyone point me in the right direction please
You can write a server application using a framework like Tornado that listens for messages on an arbitrary port.
However it sounds like you want to build a web interface. For this you should just pick a web framework. My favourite micro framework is Flask. Their quickstart I just linked to shows how easy it is to get a simple site running.
Then you would write a function for each action in the user interface. And each of those functions would be activated when the user clicks a link (or a button) that visits the associated URL.
The
'index.html'template would contain links like<a href="/dim_lights/lounge">Dim the Lights in the Lounge</a>.Does that makes sense?