After /thread/98922?sr=stream blinking an LED the next thing an IoT newb wants to do is control an LED from the web. I wanted to share what I did in the event someone else wants to do this. The app runs on SSL and requires auth to control the LED. To install I stopped the lighttpd server first.
systemctl stop lighttpd
systemctl disable lighttpd
Then install flask and pyopenssl
pip install flask
pip install pyopenssl
Download or clone the files here: https://github.com/joemcmanus/GalileoPyServer GitHub - joemcmanus/GalileoPyServer: A sample web server using Flask that can read digital & analog sensors as well as c…
Change the line
pin = mraa.Gpio(12)
Top match your pin for your LED. If you have a TMP36 temp sensor wire it up to A1.
Start the server.
Username is admin and password is galileo .
Sample wiring if you don't want to change any code.
Thanks for looking.
Absolutely. Since Flask is python you would just move your python script in to the server.py script.
from flask import Flask
return(" /runScript Run my Script ")
# Put all of your regular python code here.
# i.e. cut and paste your python script in to this section.
if __name__ == '__main__':
When you click on the link runScript it would execute your code. When it is done the text "Ran Script" would be returned to the screen. Flask is kind of amazing!