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

Uploaded Python 3

File details

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

File metadata

  • Download URL: textual_serve_asgi-0.2.1.tar.gz
  • Upload date:
  • Size: 311.9 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.1.tar.gz
Algorithm Hash digest
SHA256 bb5b74acdd484d944faa5742745e3e412c93f06cfb88fc41f76a0d8c069e1e72
MD5 0b36e653097fa11b5fff0dd09dbff10d
BLAKE2b-256 7ae130027ac77e4cc95d8a22f6fb658728fa403b251fc9a49bd0f2b89f876b70

See more details on using hashes here.

File details

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

File metadata

  • Download URL: textual_serve_asgi-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 204.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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 de34d1f79fba62a2754eaab50c440d96c74e81e2891cadec3d73e156280ad8e4
MD5 d88c0330014afaf8e3ba95d4264089b8
BLAKE2b-256 f43b627b41a6f53b28f1611f8a918060e310752bf657622a677b0e9f7f097c6d

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