mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
add websockets suppor95
This commit is contained in:
@@ -1,15 +1,24 @@
|
||||
"""Main FastAPI application"""
|
||||
import logging
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from .db.base_class import Base
|
||||
from .db.base import Base
|
||||
from .database import engine
|
||||
from .routers import auth, requests, employees
|
||||
from .websockets.notifications import notification_manager
|
||||
|
||||
# Настраиваем логирование
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Создаем таблицы в базе данных
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
app = FastAPI(title="Support API")
|
||||
app = FastAPI(
|
||||
title="Support API",
|
||||
description="API для системы поддержки IT-отдела",
|
||||
version="1.0.0"
|
||||
)
|
||||
|
||||
# Настраиваем CORS
|
||||
app.add_middleware(
|
||||
@@ -27,4 +36,15 @@ app.include_router(employees.router, prefix="/api/employees", tags=["employees"]
|
||||
|
||||
# Добавляем WebSocket маршруты
|
||||
app.websocket("/api/ws/admin")(notification_manager.admin_endpoint)
|
||||
app.websocket("/api/ws/employee/{employee_id}")(notification_manager.employee_endpoint)
|
||||
app.websocket("/api/ws/employee/{employee_id}")(notification_manager.employee_endpoint)
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup_event():
|
||||
"""Действия при запуске приложения"""
|
||||
logger.info("Starting up application...")
|
||||
# Здесь можно добавить дополнительную инициализацию
|
||||
|
||||
@app.on_event("shutdown")
|
||||
async def shutdown_event():
|
||||
"""Действия при остановке приложения"""
|
||||
logger.info("Shutting down application...")
|
Reference in New Issue
Block a user