linkedin/main.py

33 lines
1018 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
import logging
from routers import profile, jobs
# Инициализация приложения
app = FastAPI(
title="linkedin API",
description="API с linkedin получаем данные по URL",
version="1.0.0")
# Подключение роутеров
app.include_router(profile.router, tags=["Profile"])
app.include_router(jobs.router, tags=["Jobs"])
# Проверка состояния сервера
@app.get("/", tags=["Check"])
async def check():
return {"status": "ok"}
# Глобальный middleware для обработки необработанных исключений
@app.middleware("http")
async def catch_exceptions_middleware(request: Request, call_next):
try:
return await call_next(request)
except Exception as e:
logging.error(f"Unhandled exception: {str(e)}")
return JSONResponse(content={"error": "Internal Server Error"}, status_code=500)