File size: 855 Bytes
2f21db1
308b9ce
51fcfc7
ba3c9c6
51fcfc7
 
22fb250
2f21db1
 
51fcfc7
2f21db1
 
51fcfc7
1a90499
51fcfc7
ba3c9c6
 
51fcfc7
 
 
6492cc2
51fcfc7
 
ba3c9c6
 
51fcfc7
ba3c9c6
6492cc2
 
51fcfc7
 
 
 
 
 
 
 
 
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
# app.py
import os

from fastapi import FastAPI
import gradio as gr
from gradio.routes import mount_gradio_app

from src.gradio.app import build_app

# Désactiver le SSR de Gradio (pas nécessaire sur Spaces pour nous)
os.environ["GRADIO_SSR_MODE"] = "false"

print("new /")

# 1) Créer l'app FastAPI "parent"
fastapi_app = FastAPI()

# 2) Construire l'app Gradio
demo = build_app()
demo.queue()  # queue activée, comme d’habitude

# 3) Monter Gradio sur la FastAPI
app = mount_gradio_app(
    fastapi_app,
    demo,
    path="/",  # Gradio servi à la racine
)

print("new / (app mounted OK)")


# 4) Lancer uvicorn quand le script est exécuté directement
if __name__ == "__main__":
    import uvicorn

    port = int(os.getenv("PORT", "7860"))
    print(f"🚀 Starting uvicorn on 0.0.0.0:{port}")
    uvicorn.run(app, host="0.0.0.0", port=port)