Spaces:
Running
Running
| """ | |
| 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() | |