esp32-lightbar/src/lightbar/app.py

23 lines
514 B
Python

import machine
import uasyncio
from microdot_asyncio import Microdot
from lightbar.frontend import frontend
from lightbar.rest_api import rest_api
class Lightbar(Microdot):
def __init__(self):
super().__init__()
self.mount(frontend)
self.mount(rest_api, url_prefix='/api')
async def scheduled_shutdown(self):
await uasyncio.sleep(0.1)
self.shutdown()
@staticmethod
async def scheduled_reboot():
await uasyncio.sleep(0.1)
machine.reset()