Restart project based on regular ESP32 and Microdot
This commit is contained in:
parent
167847cd28
commit
56e7a1d2de
12 changed files with 1661 additions and 119 deletions
28
src/main.py
28
src/main.py
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue