File size: 859 Bytes
9e2e4e0
 
 
 
 
 
 
 
 
 
75e3709
9cbc399
75e3709
9e2e4e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import sys
from pathlib import Path

# Ensure 'src' directory is importable so we can reuse the existing Gradio app
ROOT = Path(__file__).resolve().parent
SRC = ROOT / "src"
if str(SRC) not in sys.path:
    sys.path.insert(0, str(SRC))

# Configure backend API base URL for Spaces if not set
os.environ.setdefault("API_BASE_URL", "http://129.212.240.44:80")

# Import the existing Gradio Blocks demo from src/sharp/web/app.py
from sharp.web.app import demo as _demo  # type: ignore

# Expose both names for Hugging Face Spaces compatibility
demo = _demo
app = _demo

if __name__ == "__main__":
    # On Spaces, the platform handles networking; this is for local testing
    port_env = os.getenv("PORT", "7860")
    try:
        port = int(port_env)
    except ValueError:
        port = 7860
    demo.launch(server_name="0.0.0.0", server_port=port)