Skip to content

Commit

Permalink
Use server.serve_forever instead of manually polling events.
Browse files Browse the repository at this point in the history
  • Loading branch information
lavafroth committed Mar 25, 2023
1 parent beb2f60 commit 6218883
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,11 @@ def api(request: HTTPRequest):
with HTTPResponse(request, content_type=MIMEType.TYPE_JSON) as response:
handle(json.loads(request.body), response)

server.start(str(wifi.radio.ipv4_address_ap))
while True:
try:
server.poll()
except OSError as error:
print(error)

server.serve_forever(str(wifi.radio.ipv4_address_ap))

if __name__ == "__main__":
try:
asyncio.run(main())
# For some reason, wifi.stop_ap is not implemented.
except NotImplementedError:
microcontroller.reset()

0 comments on commit 6218883

Please sign in to comment.