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

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

# ✅ Enable CORS for Swagger UI
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],  # Allow all origins (or specify ["http://localhost:7860"] for local testing)
    allow_credentials=True,
    allow_methods=["*"],  # Allow all methods
    allow_headers=["*"],  # Allow all headers
)

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

if SUPABASE_URL and SUPABASE_KEY:
    supabase = create_client(SUPABASE_URL, SUPABASE_KEY)
    print("Connected to Supabase successfully!")
else:
    print("Supabase connection failed. Please check your secrets.")

# 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!"}