Implement shutdown and reboot via API; add Makefile for deployment

This commit is contained in:
Lexi / Zoe 2022-11-05 03:18:48 +01:00
parent 56e7a1d2de
commit f16f506332
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
11 changed files with 124 additions and 14 deletions

17
src/lightbar/rest_api.py Normal file
View file

@ -0,0 +1,17 @@
import uasyncio
from microdot_asyncio import Microdot
rest_api = Microdot()
# TODO -- all of these responses aren't REST yet
@rest_api.post('/shutdown')
async def shutdown(request):
uasyncio.create_task(request.app.scheduled_shutdown())
return 'Shutting down!\n'
@rest_api.post('/reboot')
async def reboot(request):
uasyncio.create_task(request.app.scheduled_reboot())
return 'Rebooting now!\n'