Skip to main content

ASGI adapter for Textual Serve

Project description

textual-serve-asgi

ASGI adapter for Textual Serve that allows you to serve Textual apps over the web using the ASGI protocol. It can be used to mount Textual apps into FastAPI/Starlette applications.

Motivation

The original textual-serve library provides a way to serve Textual TUI apps over the web, but it runs as a standalone server. There is no built-in way to mount a Textual app as part of an existing web application.

I needed to embed a Textual app into an existing FastAPI/Starlette project as a mounted sub-application — for example, serving a Textual-based admin panel or monitoring dashboard alongside a REST API. This library bridges that gap by providing a standard ASGI interface for Textual Serve, so you can mount it at any path within your app.

It also ships with the latest xterm.js release, which adds support for in-terminal image rendering — so Textual apps that emit images (via the Kitty/iTerm/Sixel graphics protocols) display them correctly in the browser.

Installation

pip install textual-serve-asgi

# include the CLI and uvicorn for standalone serving
pip install "textual-serve-asgi[server]"

Usage

CLI

Once installed with the server extra, a textual-serve command is available. It accepts the same style of target as textual run:

# serve a Python file
textual-serve path/to/app.py

# serve a module or an installed console script
textual-serve "python -m textual"

# serve an arbitrary shell command
textual-serve -c "python -m textual"

Run textual-serve --help for the full list of options.

Standalone

from textual_serve_asgi.server import Server

server = Server("python -m textual")
server.serve()

Mounted in a Starlette/FastAPI app

from starlette.applications import Starlette

from textual_serve_asgi.server import Server

server = Server("python -m textual")

app = Starlette()
app.mount("/textual", server.asgi_app)

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

textual_serve_asgi-0.2.0.tar.gz (311.1 kB view details)

Uploaded Source

Built Distribution

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

textual_serve_asgi-0.2.0-py3-none-any.whl (203.8 kB view details)

Uploaded Python 3

File details

Details for the file textual_serve_asgi-0.2.0.tar.gz.

File metadata

  • Download URL: textual_serve_asgi-0.2.0.tar.gz
  • Upload date:
  • Size: 311.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for textual_serve_asgi-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9bcf03385c4e2e2a86fc85e1b6cde4422f27c6de208f0fc5abd837d1484eae69
MD5 09c271a82d5fd67bc97c5eaddf7483e0
BLAKE2b-256 667183d7f691fbaa90cead6e4256ca196801cf4a648d734f369297b5514a36ff

See more details on using hashes here.

File details

Details for the file textual_serve_asgi-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: textual_serve_asgi-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 203.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for textual_serve_asgi-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50a6d0215ff29a50aec52553aa18ae2b0f2261c26b745d71cdd9e6621fd161d5
MD5 38c8c328ba588bd1e6a7071dd1860040
BLAKE2b-256 fffae1be48981f63925a0fd6696bc34220cf7498febf58c1e4426ac4f17e62f1

See more details on using hashes here.

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