| | |
| | | import asyncio |
| | | from aiohttp import web |
| | | from config.logger import setup_logging |
| | | from core.api.lesson_audio_handler import LessonAudioHandler |
| | | from core.api.ota_handler import OTAHandler |
| | | from core.api.vision_handler import VisionHandler |
| | | |
| | |
| | | self.logger = setup_logging() |
| | | self.ota_handler = OTAHandler(config) |
| | | self.vision_handler = VisionHandler(config) |
| | | self.lesson_audio_handler = LessonAudioHandler(config) |
| | | |
| | | def _get_websocket_url(self, local_ip: str, port: int) -> str: |
| | | """获取websocket地址 |
| | |
| | | web.options( |
| | | "/mcp/vision/explain", self.vision_handler.handle_options |
| | | ), |
| | | web.get( |
| | | "/lesson-audio/{org_id}/index/{kind}/{level}/{story}/{lang}", |
| | | self.lesson_audio_handler.handle_index, |
| | | ), |
| | | web.get( |
| | | "/lesson-audio/{org_id}/{path:.*}", |
| | | self.lesson_audio_handler.handle_get, |
| | | ), |
| | | ] |
| | | ) |
| | | |
| | |
| | | await runner.setup() |
| | | site = web.TCPSite(runner, host, port) |
| | | await site.start() |
| | | self.lesson_audio_handler.log_ready() |
| | | |
| | | # 保持服务运行 |
| | | while True: |