Use server.serve_forever instead of manually polling events.

This commit is contained in:
Himadri Bhattacharjee
2023-03-25 14:46:50 +05:30
parent beb2f60e0f
commit 62188833f7

View File

@@ -37,16 +37,11 @@ async def main():
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()