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.1.tar.gz (14.7 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.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gradio_terminal-1.1.1.tar.gz
  • Upload date:
  • Size: 14.7 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.1.tar.gz
Algorithm Hash digest
SHA256 4a1c2df17b805f8f26983933bc7dc5d049c7f97823a48f82c1ef5afd2e5321a1
MD5 ea7d41cdab6791e265e85b11d989d2f2
BLAKE2b-256 6d77c65001247887c78d424d620862fab7e8bbb8c8680f181b0c38364662cbd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for gradio_terminal-1.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gradio_terminal-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9bc88e2d59416520662d71b4db694f4fdfb4742ba78536517a7d1b778ac384b2
MD5 dfd942bba8f597a59ed4f475792d75a0
BLAKE2b-256 74c38ef1a242890c94b834f3bc49c521119cb64973aca559617433d6f87e7f7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gradio_terminal-1.1.1-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