File size: 1,007 Bytes
0e17006
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Main app for HuggingFace Spaces - FastAPI with Gradio mounted.
FastAPI endpoints are at root, Gradio UI is at /gradio
"""
from fastapi import FastAPI
from fastapi.middleware.wsgi import WSGIMiddleware
import gradio as gr

# Import FastAPI app
from fastapi_app import app as fastapi_app

# Import Gradio app components
from app import demo as gradio_demo

# Create main FastAPI app
main_app = FastAPI(title="FaceSwapAll - Combined API and UI")

# Mount FastAPI endpoints (they're already in fastapi_app)
# We'll include them directly
main_app.mount("/api", fastapi_app)

# Mount Gradio UI
main_app.mount("/gradio", WSGIMiddleware(gradio_demo.server))

# Also include health endpoint at root
@main_app.get("/")
def root():
    return {
        "message": "FaceSwapAll API",
        "docs": "/docs",
        "gradio_ui": "/gradio",
        "api_endpoints": "/api"
    }

# Re-export for uvicorn
app = main_app

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)