home_router.py 933 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # This Python file uses the following encoding: utf-8
  2. # @author runhey
  3. # github https://github.com/runhey
  4. from fastapi import APIRouter
  5. from module.logger import logger
  6. home_app = APIRouter(
  7. prefix="/home",
  8. tags=["home"],
  9. )
  10. @home_app.get('/test')
  11. async def home_test():
  12. return {'message':'test'}
  13. # gcc -Wall -pedantic -shared -fPIC -o group_work.so group_work.c -lwiringPi
  14. @home_app.get('/home_menu')
  15. async def home_menu():
  16. return {'Home': [], 'Updater': [], 'Tool': []}
  17. @home_app.post('/notify_test')
  18. async def notify_test(setting: str, title: str, content: str):
  19. from module.notify.notify import Notifier
  20. try:
  21. notifier = Notifier(setting, True)
  22. if notifier.push(title=title, content=content):
  23. del notifier
  24. return True
  25. else:
  26. del notifier
  27. return False
  28. except Exception as e:
  29. logger.exception(e)
  30. return str(e)