CatPtain's picture
Upload 44 files
80fda88 verified
raw
history blame
2.72 kB
#!/usr/bin/env python3
"""
Huggingface Spaces entry point for MoneyPrinterTurbo
Stage 2: Streamlit Integration
"""
import os
import sys
import subprocess
# Add the root directory to Python path
root_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, root_dir)
def setup_environment():
"""Setup environment for Huggingface Spaces"""
print("πŸ“ Creating storage directories...")
# Create necessary directories
os.makedirs(os.path.join(root_dir, "storage", "tasks"), exist_ok=True)
os.makedirs(os.path.join(root_dir, "storage", "cache_videos"), exist_ok=True)
os.makedirs(os.path.join(root_dir, "storage", "temp"), exist_ok=True)
def load_env_variables():
"""Load environment variables into config"""
print("πŸ”‘ Loading environment variables...")
try:
# Try to load environment variables into config
env_vars = {
'MONEYPRINTER_API_KEY': 'api_key',
'DEEPSEEK_API_KEY': 'deepseek_api_key',
'MOONSHOT_API_KEY': 'moonshot_api_key',
'OPENAI_API_KEY': 'openai_api_key',
'PEXELS_API_KEY': 'pexels_api_keys',
'PIXABAY_API_KEY': 'pixabay_api_keys',
'AZURE_SPEECH_KEY': 'azure_speech_key',
'AZURE_SPEECH_REGION': 'azure_speech_region'
}
loaded_count = 0
for env_key, config_key in env_vars.items():
value = os.getenv(env_key)
if value:
print(f"βœ… Loaded {env_key}")
loaded_count += 1
if loaded_count > 0:
print(f"🎯 Successfully loaded {loaded_count} environment variables")
else:
print("πŸ’‘ No environment variables found - will use WebUI configuration")
except Exception as e:
print(f"⚠️ Warning loading environment variables: {e}")
def start_streamlit():
"""Start Streamlit app"""
print("πŸš€ Starting MoneyPrinterTurbo Streamlit WebUI...")
print("🎯 Stage 2: Basic Streamlit Integration")
# Setup environment first
setup_environment()
load_env_variables()
# Use SimpleMain.py for basic functionality
streamlit_app = os.path.join(root_dir, "webui", "SimpleMain.py")
# Start Streamlit using exec to replace current process
os.execvp(sys.executable, [
sys.executable, "-m", "streamlit", "run",
streamlit_app,
"--server.port=7860",
"--server.address=0.0.0.0",
"--browser.gatherUsageStats=false"
])
if __name__ == "__main__":
print("🎬 MoneyPrinterTurbo - Stage 2: Streamlit Integration")
start_streamlit()