12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #!/usr/bin/env python3
- from os import system
- from fastapi import FastAPI
- api = FastAPI()
- with open("/etc/videopc_api_key", "r") as api_file_reader:
- SECRET = api_file_reader.read().strip()
- @api.get("/" + SECRET + "/test_connection")
- async def test_connection():
- # TODO: check if daemons are running
- return {"api_online": 1}
- @api.get("/" + SECRET + "/input/pulpit")
- def switch_to_pulpit_in():
- system("hyprctl dispatch workspace 1")
- return {"success": 1}
- @api.get("/" + SECRET + "/input/rtmp")
- def switch_to_rtmp_in():
- system("hyprctl dispatch workspace 2")
- return {"success": 1}
- @api.get("/" + SECRET + "/input/black_screen")
- def switch_to_blackscreen():
- system("hyprctl dispatch workspace 3")
- return {"success": 1}
- @api.get("/" + SECRET + "/power/suspend")
- def suspend_videopc():
- system("systemctl suspend")
- return {"success": 1}
- @api.get("/" + SECRET + "/power/shutdown")
- def shutdown_videopc():
- system("shutdown now")
- return {"success": 1}
- @api.get("/" + SECRET + "/power/reboot")
- def reboot_videopc():
- system("reboot")
- return {"success": 1}
|