docstrange
docstrange copied to clipboard
feat(API): Add root path support for web interface
This pull request adds support for specifying a custom root path for the DocStrange web interface, improving flexibility for deployments under subpaths (such as behind a reverse proxy). The changes include new CLI options, updates to user instructions and output, and configuration in the web server to honor the root path.
CLI enhancements
- Added a
--root-pathargument to the CLI, allowing users to specify a custom root path for the web interface (e.g.,/docstrange). This is only used with thewebcommand.
Web server configuration
- Updated the
run_web_appfunction indocstrange/web_app.pyto accept aroot_pathargument and configure the Flask application’sAPPLICATION_ROOTaccordingly. This ensures proper routing when the app is served under a subpath. - Pass the
root_pathvalue to the static content (index.html, script.js) so that the frontend can hit the proper endpoints
Static Content
- Updated the index.html (template) to store the root_path for use on frontend resources
- Updated script.js to use the root_path if present (fallback to '') to make calls to the proper api location
@Siddhant011 @prats226