-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflask_prototype.py
More file actions
38 lines (29 loc) · 1.17 KB
/
Copy pathflask_prototype.py
File metadata and controls
38 lines (29 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from flask import Flask, render_template, request, redirect, url_for
app = Flask("ON-OFF LED")
# we are able to make 2 different requests on our webpage
# GET = we just type in the url
# POST = some sort of form submission like a button
@app.route('/', methods=['POST', 'GET'])
def hello_world():
# variables for template page (templates/index.html)
author = "Rocco"
readval = 10
# if we make a post request on the webpage aka press button then do stuff
if request.method == 'POST':
# if we press the turn on button
if request.form['submit'] == 'Turn On':
print
'TURN ON'
# if we press the turn off button
elif request.form['submit'] == 'Turn Off':
print
'TURN OFF'
else:
pass
# the default page to display will be our template with our template variables
return render_template('index.html', author=author, value=100 * (readval / 1023.))
if __name__ == "__main__":
# lets launch our webpage!
# do 0.0.0.0 so that we can log into this webpage
# using another computer on the same network later
app.run()