Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions server.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from tornado.web import RequestHandler, Application
from tornado.ioloop import IOLoop

#GPIO Setup
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
#Setup pin 3 as GPIO out to control relay module
GPIO.setup(3,GPIO.OUT)

#define main loop
def main():
try:
#GPIO Setup
GPIO.setmode(GPIO.BOARD)
#Setup pin 3 as GPIO out to control relay module
GPIO.setup(3, GPIO.OUT)

#Defining routes that can be accessed and their handlers
rutas = [('/', ListHandler),('/onoff',OnOff)]
app = Application(rutas, debug=False)
Expand All @@ -21,6 +22,9 @@ def main():
except KeyboardInterrupt:
exit()

finally:
GPIO.cleanup()

class ListHandler(RequestHandler):
def get(self):
#Renders the luz.html file
Expand Down