Metadata-Version: 2.4
Name: nanohub-gradio
Version: 0.1.0
Summary: Jupyter magic commands for configuring Gradio apps on nanoHUB
Author: nanoHUB
License: MIT
Project-URL: Homepage, https://github.com/nanohub/nanohub-gradio
Project-URL: Repository, https://github.com/nanohub/nanohub-gradio
Keywords: jupyter,gradio,nanohub,magic
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: IPython
Classifier: Framework :: Jupyter
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: ipython>=7.0
Requires-Dist: gradio>=4.0

# nanohub-gradio

[![Documentation Status](https://readthedocs.org/projects/nanohub-gradio/badge/?version=latest)](https://nanohub-gradio.readthedocs.io/en/latest/?badge=latest)

Tools for running Gradio applications on nanoHUB.

## Documentation

Full documentation is available at [https://nanohub-gradio.readthedocs.io](https://nanohub-gradio.readthedocs.io)

## Installation

```bash
pip install nanohub-gradio
```

## Features

- **Jupyter Magic Command** (`%set_gradio_env`): Configure environment variables for Gradio apps directly in Jupyter notebooks
- **Command-line Tool** (`start_gradio`): Launch Gradio applications with automatic proxy configuration

## Quick Start

### Jupyter Notebook

```python
%load_ext nanohubgradio
%set_gradio_env

import os
import gradio as gr

def greet(name):
    return f"Hello {name}!"

with gr.Blocks() as app:
    gr.Markdown("# Gradio App on nanoHUB")
    with gr.Row():
        text_input = gr.Textbox(label="Your Name")
        output = gr.Textbox(label="Greeting")
    text_input.change(greet, inputs=[text_input], outputs=[output])

if __name__ == "__main__":
    root_path = os.getenv("GRADIO_ROOT_PATH", "")
    app.launch(
        server_name="0.0.0.0",
        server_port=8001,
        root_path=root_path if root_path else None,
        share=False
    )
```

### Command Line

```bash
start_gradio --app myapp.py
```

## Environment Variables

The magic command sets the following environment variables:

- `GRADIO_ROOT_PATH` - The proxy path prefix for Gradio
- `GRADIO_HOST` - The bind host for Gradio
- `GRADIO_PORT` - The port for Gradio

## Requirements

- Python >= 3.8
- IPython >= 7.0
- Gradio >= 4.0
- Must be running on a nanoHUB environment with `SESSION` and `SESSIONDIR` environment variables set

## License

MIT License - Copyright 2026 HUBzero Foundation, LLC.
