File size: 997 Bytes
ea80cdc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
"""
Hugging Face Spaces entrypoint.

This file is intentionally minimal:
- It imports the existing Gradio Blocks app from `CodeWeaver/ui/app.py`
- It launches it with HF-friendly defaults.

Local dev remains unchanged:
  - You can still run `python CodeWeaver/ui/app.py` as before.
"""

from __future__ import annotations

import os
import sys
from pathlib import Path


def _bootstrap_import_path() -> None:
    # Make `CodeWeaver/` importable as a top-level path so we can `import ui.app`.
    repo_root = Path(__file__).resolve().parent
    codeweaver_root = repo_root / "CodeWeaver"
    sys.path.insert(0, str(codeweaver_root))


def main() -> None:
    _bootstrap_import_path()

    # Import AFTER sys.path tweak
    from ui.app import app as demo  # type: ignore

    # HF Spaces commonly provides PORT; fall back to 7860 for local.
    port = int(os.getenv("PORT", "7860"))
    demo.launch(server_name="0.0.0.0", server_port=port, show_api=False)


if __name__ == "__main__":
    main()