Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cherrypy
- import os
- import json
- import time
- import RPi.GPIO as GPIO
- class TestClass:
- @cherrypy.expose
- def __init__(self):
- GPIO.setwarnings(False)
- GPIO.setmode(GPIO.BOARD)
- GPIO.setup(31, GPIO.OUT)
- GPIO.setup(33, GPIO.OUT)
- GPIO.setup(35, GPIO.OUT)
- GPIO.setup(37, GPIO.OUT)
- GPIO.output(31, True)
- GPIO.output(33, True)
- GPIO.output(35, True)
- GPIO.output(37, True)
- @cherrypy.expose
- def index(self):
- return open('index.html')
- @cherrypy.expose
- @cherrypy.tools.json_out()
- def gpio31(self):
- GPIO.output(31, False)
- time.sleep(5)
- GPIO.output(31, True)
- @cherrypy.expose
- @cherrypy.tools.json_out()
- def gpio33(self):
- GPIO.output(33, False)
- time.sleep(5)
- GPIO.output(33, True)
- @cherrypy.expose
- @cherrypy.tools.json_out()
- def gpio35(self):
- GPIO.output(35, False)
- time.sleep(5)
- GPIO.output(35, True)
- @cherrypy.expose
- @cherrypy.tools.json_out()
- def gpio37(self):
- GPIO.output(37, False)
- time.sleep(5)
- GPIO.output(37, True)
- configfile = os.path.join(os.path.dirname(__file__),'server.conf')
- cherrypy.quickstart(TestClass(), config=configfile)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement