代码
代码: 全选
import time
import board
import digitalio
import web
status = False
relay = digitalio.DigitalInOut(board.D26)
relay.direction = digitalio.Direction.OUTPUT
relay.value = False
urls = ('/(.*)', 'call')
class call:
global status
def GET(self, action):
global status
if (action == 'status'):
if status:
return 1
else:
return 0
return "Beep bo beep!"
def POST(self, action):
global status
if (action == 'on'):
status = True
relay.value = status
elif (action == 'off'):
status = False
relay.value = status
return "Beep bo beep beep!"
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()