mirror of
https://github.com/run-llama/private-claude.git
synced 2026-07-01 20:54:04 -04:00
40 lines
951 B
Python
40 lines
951 B
Python
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
import logging
|
|
import os
|
|
import uvicorn
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.api.routers.chat import chat_router
|
|
from app.settings import init_settings
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
init_settings()
|
|
|
|
environment = os.getenv("ENVIRONMENT", "dev") # Default to 'development' if not set
|
|
|
|
|
|
if environment == "dev":
|
|
logger = logging.getLogger("uvicorn")
|
|
logger.warning("Running in development mode - allowing CORS for all origins")
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(chat_router, prefix="/api/chat")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app_host = os.getenv("APP_HOST", "0.0.0.0")
|
|
app_port = int(os.getenv("APP_PORT", "8000"))
|
|
|
|
uvicorn.run(app="main:app", host=app_host, port=app_port, reload=True)
|