forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
74 lines (56 loc) · 2.24 KB
/
Copy pathmain.py
File metadata and controls
74 lines (56 loc) · 2.24 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import os
import logging
from pathlib import Path
from dotenv import load_dotenv
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Load environment variables from the correct path
env_path = Path(__file__).parent / '.env'
logger.info(f"Loading environment variables from: {env_path}")
load_dotenv(env_path)
# Log environment variable status (without exposing secrets)
logger.info("Environment variables loaded:")
logger.info(f"OMI_APP_ID present: {'Yes' if os.getenv('OMI_APP_ID') else 'No'}")
logger.info(f"OMI_API_KEY present: {'Yes' if os.getenv('OMI_API_KEY') else 'No'}")
logger.info(f"NOTION_CLIENT_ID present: {'Yes' if os.getenv('NOTION_CLIENT_ID') else 'No'}")
logger.info(f"NOTION_CLIENT_SECRET present: {'Yes' if os.getenv('NOTION_CLIENT_SECRET') else 'No'}")
from fastapi import FastAPI, Request, Depends, HTTPException, status
from fastapi.responses import HTMLResponse, RedirectResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
import uvicorn
from src.notion import router as notion_router, init_notion_credentials
from src.omi_api import router as omi_router
from src.db import create_db_tables
# Initialize FastAPI app
app = FastAPI(title="OMI-Composio Integration")
# Mount static files
app.mount("/static", StaticFiles(directory="static"), name="static")
# Initialize templates
templates = Jinja2Templates(directory="templates")
# Initialize Notion credentials
init_notion_credentials(
client_id=os.getenv("NOTION_CLIENT_ID", ""),
client_secret=os.getenv("NOTION_CLIENT_SECRET", ""),
redirect_uri=os.getenv("NOTION_REDIRECT_URI", ""),
)
# Include routers
app.include_router(notion_router)
app.include_router(omi_router)
# Create database tables on startup
@app.on_event("startup")
async def startup_event():
create_db_tables()
# Home route
@app.get("/", response_class=HTMLResponse)
async def home(request: Request):
return templates.TemplateResponse("index.html", {"request": request})
# Health check endpoint
@app.get("/health")
async def health_check():
return {"status": "healthy"}
# Run the app
if __name__ == "__main__":
port = int(os.getenv("PORT", 8000))
uvicorn.run("main:app", host="0.0.0.0", port=port, reload=True)