Restart project based on regular ESP32 and Microdot

This commit is contained in:
Lexi / Zoe 2022-11-04 20:28:35 +01:00
parent 167847cd28
commit 56e7a1d2de
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
12 changed files with 1661 additions and 119 deletions

View file

@ -1,26 +1,12 @@
# main.py -- run after boot.py
from microdot_asyncio import Microdot
import _thread
import time
app = Microdot()
def count(name: str, stop: int = 10):
i = 0
@app.route('/')
async def index(request):
return 'Meow, world\n'
while True:
print("[{}] {}".format(name, i))
i += 1
if i > stop:
break
time.sleep(1)
print("[{}] exit".format(name))
# Start some threads
_thread.start_new_thread(count, ('thread1', 5))
_thread.start_new_thread(count, ('thread2', 3))
# Main thread
count('main', 10)
print('[main] Running Microdot app...')
app.run(port=80)