So somehow I got flask up and running. There should be a ton of articles on how to install it. I seem to remember it being pretty easy. Just google it already.
I created a new directory called party. Inside this directly I created a static and a template directory. I then created a file called app.py
Here is the app.py script
You can park all your images and such in the static folder and reference them using flask templates. In the template folder I created the look and feel I wanted for the web pages served up by flask.
You can see I call the template in the app.py with the return render_template command. So when you start a party you are quickly returned to the index.html page. Here is the index.html page
I wanted a cool DJ Air horn so I grabbed it and I am using VLC command line to run that. You will notice that the Flask is setup to run a couple other Python Scripts. This is my party start and party stop functions. These python scripts control the relay.
partyStart.py
partyStop.py
Pretty straight forward on the Relay control. You'll notice on the partyStart.py I wanted to call a little DJ airhorn to really kick the party off right. I am using the VLC command line interface to do that.
Here is what end result looks like
This can be expanded to do all sorts of fun stuff. Using this basic Flask/Python example you setup several different web based controls using Raspberry Pi.
0 comments:
Post a Comment