Spaces:
Runtime error
Runtime error
Aguilar Elizondo commited on
Commit ·
afabb78
1
Parent(s): 7480003
Add HF Spaces environment detection for proper launch
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ from PIL import Image
|
|
| 9 |
import logging
|
| 10 |
from pathlib import Path
|
| 11 |
import sys
|
|
|
|
| 12 |
|
| 13 |
# Add backend to path
|
| 14 |
sys.path.insert(0, str(Path(__file__).parent))
|
|
@@ -205,4 +206,17 @@ with gr.Blocks(title="Architecture AI Enhancer", theme=gr.themes.Soft()) as demo
|
|
| 205 |
# Launch configuration
|
| 206 |
if __name__ == "__main__":
|
| 207 |
demo.queue(max_size=10) # Enable queue for multiple users
|
| 208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
import logging
|
| 10 |
from pathlib import Path
|
| 11 |
import sys
|
| 12 |
+
import os
|
| 13 |
|
| 14 |
# Add backend to path
|
| 15 |
sys.path.insert(0, str(Path(__file__).parent))
|
|
|
|
| 206 |
# Launch configuration
|
| 207 |
if __name__ == "__main__":
|
| 208 |
demo.queue(max_size=10) # Enable queue for multiple users
|
| 209 |
+
|
| 210 |
+
# Detect if running on HF Spaces
|
| 211 |
+
is_hf_space = os.getenv("SPACE_ID") is not None
|
| 212 |
+
|
| 213 |
+
if is_hf_space:
|
| 214 |
+
# HF Spaces configuration
|
| 215 |
+
demo.launch(
|
| 216 |
+
server_name="0.0.0.0",
|
| 217 |
+
server_port=7860,
|
| 218 |
+
show_api=False
|
| 219 |
+
)
|
| 220 |
+
else:
|
| 221 |
+
# Local development
|
| 222 |
+
demo.launch(share=True)
|