Name | textual-serve JSON |
Version |
1.1.0
JSON |
| download |
home_page | None |
Summary | Turn your Textual TUIs in to web applications |
upload_time | 2024-08-30 15:53:09 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# textual-serve
Every [Textual](https://github.com/textualize/textual) application is now a web application.
With 3 lines of code, any Textual app can run in the browser.
<table>
<tr>
<td>
<p>This is <a href="https://github.com/darrenburns/posting">Posting</a> running in the terminal.</p>
</td>
<td>
<img src="https://github.com/Textualize/textual-serve/assets/554369/14120e6e-bd8c-4620-a9fc-7cf41e3e994b" width="100%"/>
</td>
</tr>
<tr>
<td>
<p>This is <a href="https://github.com/darrenburns/posting">Posting</a> running in the <em>browser</em>.</p>
</td>
<td>
<img src="https://github.com/Textualize/textual-serve/assets/554369/cfa66f9b-02a0-4335-a127-e5a75c6f859d" width="100%"/>
</td>
</tr>
</table>
---
## Getting Started
First, [install (or upgrade) Textual](https://textual.textualize.io/getting_started/#installation).
Then install `textual-serve` from PyPI:
```
pip install textual-serve
```
## Creating a server
First import the Server class:
```python
from textual_serve.server import Server
```
Then create a `Server` instance and pass the command that launches your Textual app:
```python
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:
```python
server.serve()
```
You will now be able to click on the link in the terminal to run your app in a browser.
### Summary
Run this code, visit http://localhost:8000
```python
from textual_serve.server import Server
server = Server("python -m textual")
server.serve()
```
## Configuration
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](https://textual.textualize.io/guide/devtools/).
## How does it work?
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
See also [textual-web](https://github.com/Textualize/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.
Raw data
{
"_id": null,
"home_page": null,
"name": "textual-serve",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Will McGugan <will@textualize.io>",
"download_url": "https://files.pythonhosted.org/packages/10/a7/b244754377d36dbb4cd80deb2d009977c7d5e7ebcd753f17ece675e98203/textual_serve-1.1.0.tar.gz",
"platform": null,
"description": "# textual-serve\n\nEvery [Textual](https://github.com/textualize/textual) application is now a web application.\n\nWith 3 lines of code, any Textual app can run in the browser.\n\n\n\n\n<table>\n <tr>\n <td>\n <p>This is <a href=\"https://github.com/darrenburns/posting\">Posting</a> running in the terminal.</p>\n </td>\n <td> \n <img src=\"https://github.com/Textualize/textual-serve/assets/554369/14120e6e-bd8c-4620-a9fc-7cf41e3e994b\" width=\"100%\"/>\n </td>\n </tr>\n <tr>\n <td>\n <p>This is <a href=\"https://github.com/darrenburns/posting\">Posting</a> running in the <em>browser</em>.</p>\n </td>\n <td> \n <img src=\"https://github.com/Textualize/textual-serve/assets/554369/cfa66f9b-02a0-4335-a127-e5a75c6f859d\" width=\"100%\"/>\n </td> \n </tr> \n</table>\n\n---\n\n## Getting Started\n\nFirst, [install (or upgrade) Textual](https://textual.textualize.io/getting_started/#installation).\n\nThen install `textual-serve` from PyPI:\n\n\n```\npip install textual-serve\n```\n\n## Creating a server\n\nFirst import the Server class:\n\n```python\nfrom textual_serve.server import Server\n```\n\nThen create a `Server` instance and pass the command that launches your Textual app:\n\n```python\nserver = Server(\"python -m textual\")\n```\n\nThe command can be anything you would enter in the shell, as long as it results in a Textual app running.\n\nFinally, call the `serve` method:\n\n```python\nserver.serve()\n```\n\nYou will now be able to click on the link in the terminal to run your app in a browser.\n\n### Summary\n\nRun this code, visit http://localhost:8000\n\n```python\nfrom textual_serve.server import Server\n\nserver = Server(\"python -m textual\")\nserver.serve()\n```\n\n## Configuration\n\nThe `Server` class has the following parameters:\n\n| parameter | description |\n| -------------- | ---------------------------------------------------------------------------------- |\n| command | A shell command to launch a Textual app. |\n| host | The host of the web application (defaults to \"localhost\"). |\n| port | The port for the web application (defaults to 8000). |\n| title | The title show in the web app on load, leave as `None` to use the command. |\n| public_url | The public URL, if the server is behind a proxy. `None` for the local URL. |\n| statics_path | Path to statics folder, relative to server.py. Default uses directory in module. |\n| templates_path | Path to templates folder, relative to server.py. Default uses directory in module. |\n\nThe `Server.serve` method accepts a `debug` parameter.\nWhen set to `True`, this will enable [textual devtools](https://textual.textualize.io/guide/devtools/).\n\n## How does it work?\n\nWhen you visit the app URL, the server launches an instance of your app in a subprocess, and communicates with it via a websocket.\n\nThis means that you can serve multiple Textual apps across all the CPUs on your system.\n\n\nNote that Textual-serve uses a custom protocol to communicate with Textual apps.\nIt *does not* simply expose a shell in your browser.\nThere is no way for a malicious user to do anything the app-author didn't intend.\n\n## See also\n\nSee also [textual-web](https://github.com/Textualize/textual-web) which serves Textual apps on a public URL.\n\nYou can consider this project to essentially be a self-hosted equivalent of Textual-web.\n",
"bugtrack_url": null,
"license": null,
"summary": "Turn your Textual TUIs in to web applications",
"version": "1.1.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "f843d4b1f7fdc4ff9f65682ad3e255c959660c97a2db197d40512c7a6a7b81e1",
"md5": "17fcf44019434a71353b49983daa670c",
"sha256": "aaa40bc4b75f6a1e73a2d7f6e667f5555a552d8040129a95e52789a3de5d9154"
},
"downloads": -1,
"filename": "textual_serve-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "17fcf44019434a71353b49983daa670c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 445028,
"upload_time": "2024-08-30T15:53:06",
"upload_time_iso_8601": "2024-08-30T15:53:06.591609Z",
"url": "https://files.pythonhosted.org/packages/f8/43/d4b1f7fdc4ff9f65682ad3e255c959660c97a2db197d40512c7a6a7b81e1/textual_serve-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "10a7b244754377d36dbb4cd80deb2d009977c7d5e7ebcd753f17ece675e98203",
"md5": "c18d38576ea87947e78ee545ec8b223f",
"sha256": "9332716464a1fca38bb5421ef29e38bdc5d304e5a15faa3ae1f8dcb185a7885c"
},
"downloads": -1,
"filename": "textual_serve-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "c18d38576ea87947e78ee545ec8b223f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 445952,
"upload_time": "2024-08-30T15:53:09",
"upload_time_iso_8601": "2024-08-30T15:53:09.261065Z",
"url": "https://files.pythonhosted.org/packages/10/a7/b244754377d36dbb4cd80deb2d009977c7d5e7ebcd753f17ece675e98203/textual_serve-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-30 15:53:09",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "textual-serve"
}