Spaces:
Running
Running
File size: 1,132 Bytes
177e0c5 3abb514 177e0c5 3abb514 44ee8e7 177e0c5 3abb514 f55199b 3abb514 177e0c5 3abb514 177e0c5 3abb514 |
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 |
#!/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) |