File size: 1,274 Bytes
628d40e
a9d5552
876b12f
628d40e
163d201
876b12f
 
a9d5552
 
 
628d40e
876b12f
 
a9d5552
876b12f
 
a9d5552
876b12f
a9d5552
 
876b12f
 
a9d5552
 
 
 
628d40e
 
 
 
 
a9d5552
628d40e
a9d5552
628d40e
 
876b12f
 
 
628d40e
876b12f
 
 
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
import os
from dotenv import load_dotenv
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from supabase import create_client, AsyncClient
from app.routers import analyze, health

# Load environment variables first
load_dotenv()

# FastAPI app setup
app = FastAPI(title="MediaUnmasked API")

# Configure CORS
app.add_middleware(
    CORSMiddleware,
    allow_origins=["http://localhost:5173", "http://localhost:5174"],  # Your frontend URLs
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# Print environment variables for debugging
print(f"SUPABASE_URL: {os.getenv('SUPABASE_URL')}")
print(f"SUPABASE_KEY: {os.getenv('SUPABASE_KEY')}")

# Initialize Supabase connection
SUPABASE_URL = os.getenv("SUPABASE_URL")
SUPABASE_KEY = os.getenv("SUPABASE_KEY")

if SUPABASE_URL and SUPABASE_KEY:
    print("Supabase credentials loaded successfully!")
else:
    print("Warning: Supabase credentials not found in environment variables")

# Include routers for analysis and health
app.include_router(analyze.router, prefix="/api")
app.include_router(health.router, prefix="/health")

# Test root endpoint to confirm the API is running
@app.get("/")
async def root():
    return {"message": "MediaUnmasked API is running!"}