Textual Web publishes Textual apps and terminals on the web.
Currently in a beta phase — help us test!
Textual Web is a Python application, but you don't need to be a Python developer to run it.
The easiest way to install Textual Web is via pipx. Once you have pipx installed, run the following command:
pipx install textual-web
You will now have the textual-web
command on your path.
To see what Textual Web does, run the following at the command line:
textual-web
You should see something like the following:
![Screenshot 2023-09-06 at 10 11 07](https://private-user-images.githubusercontent.com/554369/265957374-b8c6b043-57c8-4781-addf-165696f3d404.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NzQyNTEsIm5iZiI6MTcyNDU3Mzk1MSwicGF0aCI6Ii81NTQzNjkvMjY1OTU3Mzc0LWI4YzZiMDQzLTU3YzgtNDc4MS1hZGRmLTE2NTY5NmYzZDQwNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgyNVQwODE5MTFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00MjBjZWY2NjRlYmQ5NjAxNmI4NjgxNzBlOGZjODY2OTlmZTM0NzNhNjkzYjUxNTM1YzkwZWIyYzI2ODk3MjBhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.1zT1we5c92neUOOT6gC6CMiweMiWvLQng2tBzDsPugA)
Click the blue links to launch the example Textual apps (you may need to hold cmd or ctrl on some terminals). Or copy the link to your browser if your terminal doesn't support links.
You should see something like this in your browser:
![Screenshot 2023-08-22 at 09 41 35](https://private-user-images.githubusercontent.com/554369/262356498-93f70177-7b3c-4840-8265-4d8ec96c5ebc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NzQyNTEsIm5iZiI6MTcyNDU3Mzk1MSwicGF0aCI6Ii81NTQzNjkvMjYyMzU2NDk4LTkzZjcwMTc3LTdiM2MtNDg0MC04MjY1LTRkOGVjOTZjNWViYy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgyNVQwODE5MTFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iMGVkYTgzNWY1ZTM2MTU1NDNjODcyNzU0ZjQ4NzI0Y2E0ZTgzNTExMTMzYjkxMmJkMjkyZTk5MThiMzg0M2FhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.f0pjW6nddKleNQ9SzAOxxfRBSawYnlJIw15XqiSGmnI)
![Screenshot 2023-09-06 at 10 10 01](https://private-user-images.githubusercontent.com/554369/265957090-eaed134a-5fcc-40f6-8252-55cf93c84d60.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NzQyNTEsIm5iZiI6MTcyNDU3Mzk1MSwicGF0aCI6Ii81NTQzNjkvMjY1OTU3MDkwLWVhZWQxMzRhLTVmY2MtNDBmNi04MjUyLTU1Y2Y5M2M4NGQ2MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgyNVQwODE5MTFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zMGE5Y2E1ZjkwZjc2ZDlmNzMyOGJmYThlM2U3NGZiZWI4MmNlOWQ3Mjc0OTU0OWEzYmQ3MzRiNDlhMWNkZWFlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.m1v2nokejAza27JR9d3PS7TzRDnm0OUHmkc6gFm442U)
These Textual apps are running on your machine, but have public URLs. You could send the URLs to anyone with internet access, and they would see the same thing.
Hit ctrl+C in the terminal to stop serving the welcome application.
Textual Web can also serve your terminal. For quick access add the -t
switch:
textual-web -t
This will generate another URL, which will present you with your terminal in your browser:
![Screenshot 2023-08-22 at 09 42 23](https://private-user-images.githubusercontent.com/554369/262356587-99b10778-2183-4cce-9154-052a80cf6c34.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NzQyNTEsIm5iZiI6MTcyNDU3Mzk1MSwicGF0aCI6Ii81NTQzNjkvMjYyMzU2NTg3LTk5YjEwNzc4LTIxODMtNGNjZS05MTU0LTA1MmE4MGNmNmMzNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgyNVQwODE5MTFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xYzY0M2Q0OGE5ZTkyZWYxNjU5MjdmMmI3MzI2Nzc4MDU3OGFiZGUxZDEwMDU5YjQ4ZTFjYTc5ZDI3NThmZmIxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9._J27gBePq88VekUbd3fQg4NI9ELbLJjTOoVnr5CWJFo)
When you serve a terminal in this way it will generate a random public URL.
Warning
Don't share this with anyone you wouldn't trust to have access to your machine.
Textual Web can serve multiple Textual apps and terminals (as many as you like).
To demonstrate this, install Textual and clone the repository.
Navigate to the textual/examples
directory and add the following TOML file:
[app.Calculator]
command = "python calculator.py"
[app.Dictionary]
command = "python dictionary.py"
The name is unimportant, but let's say you called it "serve.toml".
Use the --config
switch to load the new configuration:
textual-web --config serve.toml
You should now get 3 links, one for each of the sections in the configuration:
![Screenshot 2023-08-22 at 10 37 59](https://private-user-images.githubusercontent.com/554369/262357388-81b966de-e95a-4672-83b9-b95c2029b942.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NzQyNTEsIm5iZiI6MTcyNDU3Mzk1MSwicGF0aCI6Ii81NTQzNjkvMjYyMzU3Mzg4LTgxYjk2NmRlLWU5NWEtNDY3Mi04M2I5LWI5NWMyMDI5Yjk0Mi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgyNVQwODE5MTFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yMzYxMDE1MDNkMzAwNjQzOWIyMGM0NjQzMmMxYTg3YmJmMzY5YmQ2ODg5YTZlMGIwZWU1Mjc0OTNiMWVmMWFhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.6RuvDjsFIKzXJxf8tA5TM3zWoai5neeMYbA2NOsJv9I)
Click any of the links to serve the respective app:
![Screenshot 2023-08-22 at 10 42 25](https://private-user-images.githubusercontent.com/554369/262357481-d25f3061-bc98-48b9-b4d0-1bab61d401b1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NzQyNTEsIm5iZiI6MTcyNDU3Mzk1MSwicGF0aCI6Ii81NTQzNjkvMjYyMzU3NDgxLWQyNWYzMDYxLWJjOTgtNDhiOS1iNGQwLTFiYWI2MWQ0MDFiMS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgyNVQwODE5MTFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03ZTQ1YWMzMTZkY2I3NjgyNDY1MDVhMDQ3ZmNjMTFjNWQ4NWFjNzllNTYzNWQzZDczOGVlY2IwMTNlYzQ2OGJlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.GTtrtczFXGKdtcOABY8MJ_DvahXl7VflBRXd9UZDb4M)
Textual Web will derive the slug (text in the URL) from the name of the app. You can also set it explicitly with the slug parameter.
[app.Calculator]
command = "python calculator.py"
slug = "calc"
Note
Terminals currently work on macOS and Linux only. Windows support is planned for a future update.
You can also add terminals to the configuration file, in a similar way.
[terminal.Terminal]
This will launch a terminal with your current shell.
You can also add a command
value to run a command other than your shell.
For instance, let's say we want to serve the htop
command.
We could add the following to the configuration:
[terminal.HTOP]
command = "htop"
In previous examples, the URLs all contained a random string of digits which will change from run to run. If you want to create a permanent URL you will need to create an account.
To create an account, run the following command:
textual-web --signup
This will bring up a dialog in your terminal that looks something like this:
![Screenshot 2023-08-22 at 09 43 03](https://private-user-images.githubusercontent.com/554369/262357291-9601eee1-7733-4e8a-a401-78402cfd1cca.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NzQyNTEsIm5iZiI6MTcyNDU3Mzk1MSwicGF0aCI6Ii81NTQzNjkvMjYyMzU3MjkxLTk2MDFlZWUxLTc3MzMtNGU4YS1hNDAxLTc4NDAyY2ZkMWNjYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgyNVQwODE5MTFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lMjRhYmNiMDQwMWQ4OTU1MjU4NWYyZWY2ZDM4YWE3ZjIzYzg4NWJlODg3NjE3NzZjY2JiOGU2MjQxODU0NGM3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.QTDVBOcD4m_DUH5UvUr8IDcrvvLL9IHHc_SJ3jmyic0)
If you fill in that dialog, it will create an account for you and generate a file called "ganglion.toml". At the top of that file you will see a section like the following:
[account]
api_key = "JSKK234LLNWEDSSD"
You can add that to your configuration file, or edit "ganglion.toml" with your apps / terminals. Run it as you did previously:
textual-web --config ganglion.toml
Now the URLs generated by textual-web
will contain your account slug in the first part of the path.
The account slug won't change, so you will get the same URLs from one run to the next.
For a little more visibility on what is going on "under the hood", set the DEBUG
environment variable:
DEBUG=1 textual-web --config ganglion.toml
Note this may generate a lot of output, and it may even slow your apps down.
You may encounter a glitch with apps that have a lot of colors. This is a bug in an upstream library, which we are expecting a fix for soon.
The experience on mobile may vary. On iPhone Textual apps are quite usable, but other systems may have a few issues. We should be able to improve the mobile exprience in future updates.
The goal of this project is to turn Textual apps into fully featured web applications.
Currently serving Textual apps and terminals appears very similar. In fact, if you serve a terminal and then launch a Textual app, it will work just fine in the browser. Under the hood, however, Textual apps are served using a custom protocol. This protocol will be used to expose web application features to the Textual app.
For example, a Textual app might generate a file (say a CSV with a server report). If you run that in the terminal, the file would be saved in your working directory. But in a Textual app it would be served and saved in your Downloads folder, like a regular web app.
In the future, other web APIs can be exposed to Textual apps in a similar way.
Also planned for the near future is sessions. Currently, if you close the browser tab it will also close the Textual app. In the future you will be able to close a tab and later resume where you left off. This will also allow us to upgrade servers without kicking anyone off.
Currently testing is being coordinated via our Discord server. Join us if you would like to participate.