|
|
|
|
|
"""
|
|
|
Huggingface Spaces entry point for MoneyPrinterTurbo
|
|
|
This file replaces main.py for HF Spaces deployment
|
|
|
"""
|
|
|
import os
|
|
|
import sys
|
|
|
import subprocess
|
|
|
import time
|
|
|
|
|
|
|
|
|
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...")
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
os.environ["STREAMLIT_SERVER_PORT"] = "7860"
|
|
|
os.environ["STREAMLIT_SERVER_ADDRESS"] = "0.0.0.0"
|
|
|
os.environ["STREAMLIT_BROWSER_GATHER_USAGE_STATS"] = "false"
|
|
|
os.environ["STREAMLIT_SERVER_ENABLE_CORS"] = "true"
|
|
|
|
|
|
def setup_api_keys_from_env():
|
|
|
"""Setup API keys from environment variables (minimal version)"""
|
|
|
try:
|
|
|
from app.config import config
|
|
|
|
|
|
|
|
|
if os.getenv("MONEYPRINTER_API_KEY"):
|
|
|
config.app["api_key"] = os.getenv("MONEYPRINTER_API_KEY")
|
|
|
config.app["api_enabled"] = True
|
|
|
print("β
API access configured")
|
|
|
|
|
|
|
|
|
config.save_config()
|
|
|
|
|
|
except Exception as e:
|
|
|
print(f"β οΈ Warning: {e}")
|
|
|
print("π‘ Configure API keys in WebUI after startup")
|
|
|
|
|
|
def start_streamlit():
|
|
|
"""Start Streamlit app optimized for HF Spaces"""
|
|
|
print("π Starting MoneyPrinterTurbo WebUI...")
|
|
|
|
|
|
|
|
|
streamlit_cmd = [
|
|
|
sys.executable, "-m", "streamlit", "run",
|
|
|
os.path.join(root_dir, "webui", "Main.py"),
|
|
|
"--server.port", "7860",
|
|
|
"--server.address", "0.0.0.0",
|
|
|
"--browser.gatherUsageStats", "false",
|
|
|
"--server.enableCORS", "true",
|
|
|
"--server.enableXsrfProtection", "false",
|
|
|
"--server.enableWebsocketCompression", "false"
|
|
|
]
|
|
|
|
|
|
print(f"π― Starting Streamlit on port 7860...")
|
|
|
print(f"π Command: {' '.join(streamlit_cmd)}")
|
|
|
|
|
|
|
|
|
os.execvp(sys.executable, streamlit_cmd)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
print("π MoneyPrinterTurbo - Huggingface Spaces")
|
|
|
|
|
|
|
|
|
setup_environment()
|
|
|
setup_api_keys_from_env()
|
|
|
|
|
|
|
|
|
start_streamlit() |