-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapp.py
More file actions
60 lines (48 loc) · 1.59 KB
/
app.py
File metadata and controls
60 lines (48 loc) · 1.59 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from fastapi import FastAPI
import asyncio
import logging
import os
from database.database import init_db
# Import routers
from api.upload import router as upload_router
from api.search import router as search_router
from api.feedback import router as feedback_router
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Create FastAPI app with production settings
# Enable docs unless explicitly disabled
enable_docs = os.getenv("DISABLE_DOCS", "false").lower() != "true"
app = FastAPI(
title="Semantic Search API",
description="AI-powered semantic search for company data",
version="2.0.0",
docs_url="/docs" if enable_docs else None,
redoc_url="/redoc" if enable_docs else None,
)
# Include routers
app.include_router(upload_router, prefix="/api")
app.include_router(search_router, prefix="/api")
app.include_router(feedback_router, prefix="/api")
@app.on_event("startup")
async def on_startup():
"""Initialize database on startup"""
try:
logger.info("Starting database initialization...")
await init_db()
logger.info("Database initialization completed successfully")
except Exception as e:
logger.error(f"Database Initialization failed: {e}")
raise e
@app.get("/")
async def root():
"""Health check endpoint"""
return {"message": "Semantic Search API is running", "status": "healthy"}
@app.get("/health")
async def health_check():
"""Detailed health check endpoint"""
return {
"status": "healthy",
"service": "semantic_search_api",
"version": "1.0.0"
}