Spaces:
Running
Running
#!/usr/bin/env python3 | |
""" | |
Session-isolated app.py for HuggingFace Spaces deployment | |
Ensures each user gets their own isolated app instance | |
""" | |
import os | |
from dotenv import load_dotenv | |
from gradio_interface import create_session_isolated_interface | |
load_dotenv() | |
def create_app(): | |
"""Creates session-isolated Gradio app for Hugging Face Space""" | |
return create_session_isolated_interface() | |
if __name__ == "__main__": | |
if not os.getenv("GEMINI_API_KEY"): | |
print("β οΈ GEMINI_API_KEY not found in environment variables!") | |
print("For local run, create .env file with API key") | |
demo = create_session_isolated_interface() | |
is_hf_space = os.getenv("SPACE_ID") is not None | |
if is_hf_space: | |
print("π **SESSION ISOLATION ENABLED**") | |
print("β Each user gets private, isolated app instance") | |
print("β No data mixing between concurrent users") | |
demo.launch( | |
server_name="0.0.0.0", | |
server_port=7860, | |
show_api=False, | |
show_error=True | |
) | |
else: | |
demo.launch(share=True, debug=True) |