mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 01:21:48 +03:00
3ffe6a8d5a
reduce sampling
53 lines
1.2 KiB
Python
53 lines
1.2 KiB
Python
import os
|
|
|
|
from packages.utils import handle_request_validation_error
|
|
|
|
if __name__ == "__main__":
|
|
# import needed here when running main.py to debug backend
|
|
# you will need to run pip install python-dotenv
|
|
from dotenv import load_dotenv # type: ignore
|
|
|
|
load_dotenv()
|
|
import sentry_sdk
|
|
from fastapi import FastAPI, HTTPException
|
|
from fastapi.responses import JSONResponse
|
|
from logger import get_logger
|
|
from middlewares.cors import add_cors_middleware
|
|
from routes.crawl_routes import crawl_router
|
|
from routes.misc_routes import misc_router
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
sentry_dsn = os.getenv("SENTRY_DSN")
|
|
if sentry_dsn:
|
|
sentry_sdk.init(
|
|
dsn=sentry_dsn,
|
|
traces_sample_rate=0.1,
|
|
profiles_sample_rate=0.1,
|
|
)
|
|
|
|
app = FastAPI()
|
|
|
|
add_cors_middleware(app)
|
|
|
|
|
|
app.include_router(crawl_router)
|
|
app.include_router(misc_router)
|
|
|
|
|
|
@app.exception_handler(HTTPException)
|
|
async def http_exception_handler(_, exc):
|
|
return JSONResponse(
|
|
status_code=exc.status_code,
|
|
content={"detail": exc.detail},
|
|
)
|
|
|
|
|
|
handle_request_validation_error(app)
|
|
|
|
if __name__ == "__main__":
|
|
# run main.py to debug backend
|
|
import uvicorn
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=5050)
|