lidavidsh/ml-sharp
1
1import os2import sys3from pathlib import Path4 5# Ensure 'src' directory is importable so we can reuse the existing Gradio app6ROOT = Path(__file__).resolve().parent7SRC = ROOT / "src"8if str(SRC) not in sys.path:9 sys.path.insert(0, str(SRC))10 11# Configure backend API base URL for Spaces if not set12os.environ.setdefault("API_BASE_URL", "http://129.212.240.44:80")13 14# Import the existing Gradio Blocks demo from src/sharp/web/app.py15from sharp.web.app import demo as _demo # type: ignore16 17# Expose both names for Hugging Face Spaces compatibility18demo = _demo19app = _demo20 21if __name__ == "__main__":22 # On Spaces, the platform handles networking; this is for local testing23 port_env = os.getenv("PORT", "7860")24 try:25 port = int(port_env)26 except ValueError:27 port = 786028 demo.launch(server_name="0.0.0.0", server_port=port)29 