-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
44 lines (35 loc) · 1.44 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
"""Server"""
__copyright__ = "Copyright (c) 2024 STAIR. All Rights Reserved."
__email__ = "[email protected]"
import asyncio
import os
from aiohttp import web
from aiohttp_session import setup
from aiohttp_session.cookie_storage import EncryptedCookieStorage
from integration.manager import IntegrationManager
from .db_import import DbImportHandler
from .announcement import AnnouncementHandler
from .foodstoffi_menu_trigger import FoodstoffMenuTrigger
from .msal_auth.handler import MsalAuth
class WebServer:
"""The main entry point for the web server."""
__slots__ = (
"_db_import_handler",
"_announcement_handler",
"_foodstoffi_menu_trigger",
"_msal",
"_integration_manager",
)
def __init__(self, app: web.Application) -> None:
self._integration_manager = IntegrationManager()
self._db_import_handler = DbImportHandler(app, self._integration_manager)
self._announcement_handler = AnnouncementHandler(app, self._integration_manager)
self._foodstoffi_menu_trigger = FoodstoffMenuTrigger(
app, self._integration_manager
)
self._msal = MsalAuth(app, self._integration_manager)
setup(app, EncryptedCookieStorage(os.getenv("SESSION_SECRET", "").encode()))
app.on_startup.append(self._on_startup)
async def _on_startup(self, _: web.Application) -> None:
asyncio.create_task(self._integration_manager.start())