fully implemented project

This commit is contained in:
2026-01-22 19:17:50 +01:00
parent aea6950bfe
commit 42d2758ba5
11 changed files with 220 additions and 5 deletions

View File

@@ -1 +1,41 @@
print("hello")
import signal
import sys
import os
import logger
from server import Server
def _handle_exit(sig, frame):
print("Exiting...")
sys.exit(0)
def _get_environment_variable(key: str) -> str:
value = os.getenv(key)
if not value:
logger.error("Environment variable '" + key + "' must be set")
return value
def _parse_environment_variable(key: str, value: str) -> int | None:
try:
return int(value)
except ValueError:
logger.error("Environment variable '" + key + "' must be an integer")
def main():
signal.signal(signal.SIGTERM, _handle_exit)
signal.signal(signal.SIGINT, _handle_exit)
host = _get_environment_variable("HOST")
port = _get_environment_variable("PORT")
cache_duration = _get_environment_variable("CACHE_DURATION")
ics_url = _get_environment_variable("ICS_URL")
port_int = _parse_environment_variable("PORT", port)
cache_duration_int = _parse_environment_variable("CACHE_DURATION", cache_duration)
server = Server(host, port_int, cache_duration_int, ics_url)
server.serve()
if __name__ == "__main__":
main()