Created
May 14, 2022 01:34
-
-
Save ckdake/98ea451e2beff9cb7067b0f3af04fd09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment