Hardware Reference
In-Depth Information
Engage thrusters
1. The irst part is seing up the landing page. When a user enters the address of the
web server, the web page would be something like what is shown in the following
screenshot. The HTML page consists of a single buton called Sample Buton .
A flask framework-based web server
2.
When a buton is clicked, the incoming POST request is used to switch the states of
the LED from ON to OFF and vice versa:
@app.route('/', methods=['POST'])
def record():
#record all the data from the form
global state
if state == False:
state = True
else:
state = False
GPIO.output(25,state)
return render_template('form_submit.html')
3.
The web server can be launched from the IP address of Raspberry Pi. The web page
should be accessible from htt p://192.168.1.76:75 :
# Run the app :)
if __name__ == '__main__':
app.run(
host="0.0.0.0",
port=int("75")
)\
The web server example is available along with this project. Check this topic's website for
more examples.
 
Search WWH ::




Custom Search