Spaces:
Sleeping
Sleeping
Déploiement depuis GitHub Actions
Browse files- space_app.py +8 -2
space_app.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
"""Point d'entrée du Space Hugging Face (SDK Gradio).
|
| 2 |
|
| 3 |
L'API FastAPI (app/main.py) reste le cœur du service : on y monte une interface Gradio
|
| 4 |
-
sur /gradio, et on sert le tout avec uvicorn sur le port
|
| 5 |
"""
|
|
|
|
|
|
|
| 6 |
import gradio as gr
|
| 7 |
import uvicorn
|
| 8 |
|
|
@@ -33,4 +35,8 @@ demo = gr.Interface(
|
|
| 33 |
app = gr.mount_gradio_app(app, demo, path="/gradio")
|
| 34 |
|
| 35 |
if __name__ == "__main__":
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
"""Point d'entrée du Space Hugging Face (SDK Gradio).
|
| 2 |
|
| 3 |
L'API FastAPI (app/main.py) reste le cœur du service : on y monte une interface Gradio
|
| 4 |
+
sur /gradio, et on sert le tout avec uvicorn sur le port attendu par Hugging Face.
|
| 5 |
"""
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
import gradio as gr
|
| 9 |
import uvicorn
|
| 10 |
|
|
|
|
| 35 |
app = gr.mount_gradio_app(app, demo, path="/gradio")
|
| 36 |
|
| 37 |
if __name__ == "__main__":
|
| 38 |
+
# Sur Hugging Face, le port et l'adresse sont fournis par les variables de Gradio
|
| 39 |
+
host = os.getenv("GRADIO_SERVER_NAME", "0.0.0.0")
|
| 40 |
+
port = int(os.getenv("GRADIO_SERVER_PORT", "7860"))
|
| 41 |
+
print(f"Démarrage sur {host}:{port}")
|
| 42 |
+
uvicorn.run(app, host=host, port=port)
|