Files
gniza4linux/tui/__main__.py
shuki bd25d99056 Fix web GUI by setting PYTHONPATH in spawned command
textual-serve spawns the app as a subprocess which doesn't
inherit PYTHONPATH. Bake the project root into the command.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 00:55:43 +02:00

29 lines
757 B
Python

import os
import sys
from pathlib import Path
from tui.app import GnizaApp
# Resolve project root (parent of tui/)
_PROJECT_ROOT = str(Path(__file__).resolve().parent.parent)
def main():
if "--web" in sys.argv:
from textual_serve.server import Server
port = 8080
for i, arg in enumerate(sys.argv):
if arg == "--port" and i + 1 < len(sys.argv):
port = int(sys.argv[i + 1])
env_path = f"{_PROJECT_ROOT}:{os.environ.get('PYTHONPATH', '')}"
cmd = f"PYTHONPATH={env_path} GNIZA_DIR={_PROJECT_ROOT} python3 -m tui"
server = Server(cmd, host="0.0.0.0", port=port)
server.serve()
else:
app = GnizaApp()
app.run()
if __name__ == "__main__":
main()