30 lines
901 B
Python
30 lines
901 B
Python
from fastapi import FastAPI
|
|
from app.router import router
|
|
from app.utils.response_wrapper import standard_response
|
|
from app.exception_handlers import (
|
|
validation_exception_handler,
|
|
http_exception_handler,
|
|
general_exception_handler
|
|
)
|
|
from fastapi.exceptions import RequestValidationError
|
|
from starlette.exceptions import HTTPException as StarletteHTTPException
|
|
|
|
app = FastAPI(
|
|
title="Vector Search API",
|
|
version="1.0.0",
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
openapi_url="/openapi.json"
|
|
)
|
|
|
|
# 注册自定义异常处理器
|
|
app.add_exception_handler(RequestValidationError, validation_exception_handler)
|
|
app.add_exception_handler(StarletteHTTPException, http_exception_handler)
|
|
app.add_exception_handler(Exception, general_exception_handler)
|
|
app.include_router(router)
|
|
|
|
@app.get("/")
|
|
@standard_response
|
|
def root():
|
|
return {"message": "Vector Search API is running"}
|