API Reference
This section provides detailed API documentation for the nanohub-gradio package.
Jupyter Magic Command
- %set_dash_env [--port PORT] [--host HOST]
Configure environment variables for running Dash on nanoHUB.
Environment Variables Set:
DASH_REQUESTS_PATHNAME_PREFIX: Weber proxy path for requests (e.g.,/weber/123/abc/456/proxy/8001/)DASH_ROUTES_PATHNAME_PREFIX: Set to/DASH_HOST: The host address for the Dash serverDASH_PORT: The port number for the Dash serverDASH_BASE_PROXY: Base proxy URL (e.g.,https://proxy.nanohub.org)
Example:
%load_ext nanohubdash %set_dash_env --port 8050 --host 0.0.0.0
Command-Line Tool
start_dash
Launch a Dash application with automatic proxy configuration and header injection.
Usage:
start_dash --app APP_PATH [--debug DEBUG] [--logo LOGO_URL]
Arguments:
- --app APP_PATH
Required. Path to the Dash application Python file. The file must define
app = dash.Dash(...).
- --debug DEBUG
Optional. Enable debug mode (True/False). Default: False. When enabled:
Hot reloading is active
Detailed error messages are shown
wrwroxy stream logging is enabled
- --logo LOGO_URL
Optional. URL for the logo displayed in the header bar. Default: nanoHUB logo
Example:
start_dash --app myapp.py --debug True --logo https://example.com/logo.png
Header Injection:
When using start_dash, a header bar is automatically injected into your Dash app with:
Logo image (customizable via
--logo)“Submit a ticket” link for support
“Terminate Session” button
Python API
nanohubdash module
- nanohubdash.__version__
The current version of the nanohub-gradio package.
- nanohubdash.load_ipython_extension(ipython)
Register the SetDashEnvMagic with IPython.
This function is called automatically when the extension is loaded via
%load_ext nanohubdash.- Parameters:
ipython – The IPython shell instance.
- class nanohubdash.SetDashEnvMagic
IPython magic class for setting up Dash environment on nanoHUB.
Provides the
%set_dash_envline magic that configures environment variables needed for Dash applications running behind the nanoHUB weber proxy.
Environment Variables Reference
The following environment variables are used or set by nanohub-gradio:
Input Variables (read from environment):
Variable |
Description |
|---|---|
|
nanoHUB session identifier |
|
Path to session directory containing resources file |
Output Variables (set by nanohub-gradio):
Variable |
Description |
|---|---|
|
Full weber proxy path for Dash requests |
|
Always set to |
|
Host address for Dash server |
|
Port number for Dash server |
|
Base proxy URL (e.g., |
Additional Variables (set by start_dash):
Variable |
Description |
|---|---|
|
Host for the Dash server (used internally) |
|
Port for the Dash server (used internally) |
|
Debug mode flag |
|
Detected application name |