diff --git a/docstrange/cli.py b/docstrange/cli.py index dff3271..6202dfd 100644 --- a/docstrange/cli.py +++ b/docstrange/cli.py @@ -175,7 +175,8 @@ def main(): # Start web interface docstrange web # Start web interface at http://localhost:8000 - + docstrange web --root-path /docstrange # Start at http://localhost:8000/docstrange + # Convert a PDF to markdown (default cloud mode) docstrange document.pdf @@ -338,7 +339,13 @@ def main(): action="store_true", help="Clear cached authentication credentials" ) - + + parser.add_argument( + "--root-path", + default="", + help="Root path for the web server (e.g., '/docstrange'). Only used with 'web' command." + ) + args = parser.parse_args() # Handle version flag @@ -368,9 +375,10 @@ def main(): try: from .web_app import run_web_app print("Starting DocStrange web interface...") - print("Open your browser and go to: http://localhost:8000") + base_url = f"http://localhost:8000{args.root_path}" if args.root_path else "http://localhost:8000" + print(f"Open your browser and go to: {base_url}") print("Press Ctrl+C to stop the server") - run_web_app(host='0.0.0.0', port=8000, debug=False) + run_web_app(host='0.0.0.0', port=8000, debug=False, root_path=args.root_path) return 0 except ImportError: print("❌ Web interface not available. Install Flask: pip install Flask", file=sys.stderr) diff --git a/docstrange/static/script.js b/docstrange/static/script.js index 5d8404d..344d4fd 100644 --- a/docstrange/static/script.js +++ b/docstrange/static/script.js @@ -4,6 +4,8 @@ class DocStrangeApp { constructor() { this.selectedFile = null; this.extractionResults = null; + // Get root path from global config, default to empty string + this.rootPath = window.APP_ROOT_PATH || ''; this.initializeApp(); } @@ -14,7 +16,7 @@ class DocStrangeApp { async loadSystemInfo() { try { - const response = await fetch('/api/system-info'); + const response = await fetch(`${this.rootPath}/api/system-info`); if (response.ok) { const systemInfo = await response.json(); this.updateProcessingModeOptions(systemInfo); @@ -169,7 +171,7 @@ class DocStrangeApp { // Use cloud processing mode by default formData.append('processing_mode', 'cloud'); - const response = await fetch('/api/extract', { + const response = await fetch(`${this.rootPath}/api/extract`, { method: 'POST', body: formData }); diff --git a/docstrange/templates/index.html b/docstrange/templates/index.html index 8685d7d..a2a1ca5 100644 --- a/docstrange/templates/index.html +++ b/docstrange/templates/index.html @@ -591,6 +591,12 @@
+ + +