Skip to main content

A Gradio component that provides a fully functional terminal using xterm.js and PTY

Project description

Gradio Terminal

PyPI PyPI Downloads GitHub license Coding style

A Gradio component that provides a fully functional terminal in your browser. This package uses xterm.js on the frontend and a PTY on the backend to provide a real shell experience.

Gradio Terminal

Installation

pip install gradio-terminal

Quick Start

Simple Usage

import gradio as gr
from gradio_terminal import Terminal
demo = gr.Blocks()
with demo:
    terminal = Terminal()
demo.launch()

Secure Terminal (No Sudo)

with demo:
    terminal = Terminal(allow_sudo=False)  # Block sudo commands

Terminal with Blacklist

with demo:
    terminal = Terminal(
        blacklist_commands=["rm", "shutdown", "reboot"]  # Block dangerous commands
    )

API Reference

Function Parameters Description
launch_terminal() port=5000, host="127.0.0.1", command="bash", share=False, allow_sudo=True, blacklist_commands=None, **launch_kwargs Launch a standalone Gradio app with a terminal.
create_terminal_demo() port=5000, host="127.0.0.1", command="bash", height=400, allow_sudo=True, blacklist_commands=None Create a Gradio Blocks demo with an embedded terminal.
Terminal() port=5000, host="127.0.0.1", command="bash", height=400, label=None, visible=True, elem_id=None, elem_classes=None, allow_sudo=True, blacklist_commands=None Create a terminal component for Gradio Blocks.
TerminalServer() port=5000, host="127.0.0.1", command="bash" Low-level terminal server for custom integrations.

TerminalServer Methods

Method Description
start() Start the server and return the URL
get_url() Get the terminal server URL
stop() Stop the terminal server

Notes

  • allow_sudo: Whether to allow sudo commands (default: True). When False, sudo commands are blocked with an error message.
  • blacklist_commands: List of commands to block (default: None). Any command in this list will be blocked with an error message.

Security

This component provides shell access to your server. Use the allow_sudo=False parameter to block sudo commands and the blacklist_commands parameter to block specific dangerous commands for enhanced security:

terminal = Terminal(
    allow_sudo=False,
    blacklist_commands=["rm", "shutdown", "reboot", "passwd"]
)

Disclaimer and Security Notice

This component provides shell access to your server, which can pose significant security risks if misused. It should only be used in trusted environments. While this package provides settings such as allow_sudo=False and blacklist_commands to reduce potential threats, it does not guarantee complete security. The authors are not responsible for any misuse or damage caused by this component.

License

This project is licensed under the Apache-2.0 License.

Acknowledgments

  • pyxtermjs - Inspiration for the terminal implementation
  • xterm.js - Terminal emulator for the browser
  • Gradio - The awesome ML demo framework

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gradio_terminal-1.1.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gradio_terminal-1.1.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file gradio_terminal-1.1.0.tar.gz.

File metadata

  • Download URL: gradio_terminal-1.1.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gradio_terminal-1.1.0.tar.gz
Algorithm Hash digest
SHA256 76511f4ff0b62dad884104c8ccc83332839be8772d15f4965cc2fc4c7c679b70
MD5 63c1430b7c3efaf3b56557da32712ae8
BLAKE2b-256 7674974b32c61018e633742b81c747f15c582aea063cff6521c10f23b9650c48

See more details on using hashes here.

Provenance

The following attestation bundles were made for gradio_terminal-1.1.0.tar.gz:

Publisher: publish-to-pypi.yml on aben20807/gradio-terminal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gradio_terminal-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gradio_terminal-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6301f816aedac3f7b8ba37540349d886ef0b8d7bf2e2e5103320e9e1d64a286e
MD5 f9fd59466ef133b05f8e384322dd4952
BLAKE2b-256 a7270dcb88d3b98a8d7845223ae8c534dd20a9841e37f30700fb2c4fbfcb0828

See more details on using hashes here.

Provenance

The following attestation bundles were made for gradio_terminal-1.1.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on aben20807/gradio-terminal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page