39 lines
963 B
Python
39 lines
963 B
Python
import os
|
|
import sys
|
|
import logging
|
|
from dotenv import load_dotenv
|
|
|
|
# Load environment variables from .env file
|
|
load_dotenv()
|
|
|
|
# Add the parent directory to the path
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
# Configure logging
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
import uvicorn
|
|
|
|
if __name__ == "__main__":
|
|
# Get port from environment variable or use default
|
|
port = int(os.environ.get("PORT", 8001))
|
|
|
|
# Import the app here to ensure environment variables are set first
|
|
from api.api import app
|
|
|
|
logger.info(f"Starting Red Mountain Dev Assistant API on port {port}")
|
|
logger.info("Make sure you have configured your API keys in .env file")
|
|
|
|
# Run the FastAPI app with uvicorn
|
|
uvicorn.run(
|
|
"api.api:app",
|
|
host="0.0.0.0",
|
|
port=port,
|
|
reload=True,
|
|
)
|
|
|