Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Every Textual application is now a web application.
With 3 lines of code, any Textual app can run in the browser.
This is Posting running in the terminal. | |
This is Posting running in the browser. |
First, install (or upgrade) Textual.
Then install textual-serve
from PyPI:
pip install textual-serve
First import the Server class:
from textual_serve.server import Server
Then create a Server
instance and pass the command that launches your Textual app:
server = Server("python -m textual")
The command can be anything you would enter in the shell, as long as it results in a Textual app running.
Finally, call the serve
method:
server.serve()
You will now be able to click on the link in the terminal to run your app in a browser.
Run this code, visit http://localhost:8000
from textual_serve.server import Server
server = Server("python -m textual")
server.serve()
The Server
class has the following parameters:
parameter | description |
---|---|
command | A shell command to launch a Textual app. |
host | The host of the web application (defaults to "localhost"). |
port | The port for the web application (defaults to 8000). |
title | The title show in the web app on load, leave as None to use the command. |
public_url | The public URL, if the server is behind a proxy. None for the local URL. |
statics_path | Path to statics folder, relative to server.py. Default uses directory in module. |
templates_path | Path to templates folder, relative to server.py. Default uses directory in module. |
The Server.serve
method accepts a debug
parameter.
When set to True
, this will enable textual devtools.
When you visit the app URL, the server launches an instance of your app in a subprocess, and communicates with it via a websocket.
This means that you can serve multiple Textual apps across all the CPUs on your system.
Note that Textual-serve uses a custom protocol to communicate with Textual apps. It does not simply expose a shell in your browser. There is no way for a malicious user to do anything the app-author didn't intend.
See also textual-web which serves Textual apps on a public URL.
You can consider this project to essentially be a self-hosted equivalent of Textual-web.
FAQs
Turn your Textual TUIs in to web applications
We found that textual-serve demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.