Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,10 +19,18 @@ if not HF_TOKEN:
|
|
| 19 |
|
| 20 |
# Initialize backend client
|
| 21 |
try:
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
print(f"Connected to backend at {BACKEND_URL}")
|
| 24 |
except Exception as e:
|
| 25 |
print(f"Warning: Could not connect to backend: {e}")
|
|
|
|
| 26 |
backend_client = None
|
| 27 |
|
| 28 |
def add_sentences_ui(sentences_text):
|
|
@@ -238,5 +246,7 @@ with gr.Blocks(title="RAM-P - Interactive Learning") as frontend_app:
|
|
| 238 |
""")
|
| 239 |
|
| 240 |
if __name__ == "__main__":
|
| 241 |
-
|
|
|
|
|
|
|
| 242 |
|
|
|
|
| 19 |
|
| 20 |
# Initialize backend client
|
| 21 |
try:
|
| 22 |
+
# For private Spaces, pass token via headers or use HF_TOKEN environment variable
|
| 23 |
+
# Gradio Client automatically uses HF_TOKEN env var if available
|
| 24 |
+
if HF_TOKEN:
|
| 25 |
+
# Set as environment variable for gradio-client to pick up
|
| 26 |
+
os.environ["HF_TOKEN"] = HF_TOKEN
|
| 27 |
+
backend_client = Client(BACKEND_URL)
|
| 28 |
+
else:
|
| 29 |
+
backend_client = Client(BACKEND_URL)
|
| 30 |
print(f"Connected to backend at {BACKEND_URL}")
|
| 31 |
except Exception as e:
|
| 32 |
print(f"Warning: Could not connect to backend: {e}")
|
| 33 |
+
print(f"Make sure BACKEND_URL and HF_TOKEN are set correctly.")
|
| 34 |
backend_client = None
|
| 35 |
|
| 36 |
def add_sentences_ui(sentences_text):
|
|
|
|
| 246 |
""")
|
| 247 |
|
| 248 |
if __name__ == "__main__":
|
| 249 |
+
# Let Gradio use default port (7860) or GRADIO_SERVER_PORT env var
|
| 250 |
+
# Don't hardcode port - let Hugging Face Spaces handle it
|
| 251 |
+
frontend_app.launch()
|
| 252 |
|