This commit is contained in:
Will McGugan
2024-08-30 18:49:33 +01:00
parent ea03bbc757
commit 66132b8c42

View File

@@ -59,6 +59,39 @@ For instance, the following will run the `textual colors` command:
textual run -c textual colors
```
### Serve
The devtools can also serve your application in a browser.
Effectively turning your terminal app in to a web application!
The `serve` sub-command is similar to `run`. Here's how you can serve an app launched from a Python file:
```
textual serve my_app.py
```
You can also serve a Textual app launched via a command. Here's an example:
```
textual serve "textual keys"
```
The syntax for launching an app in a module is slightly different from `run`.
You need to specify the full command, including `python`.
Here's how you would run the Textual demo:
```
textual serve "python -m textual"
```
Textual's builtin web-server is quite powerful.
You can serve multiple instances of your application at once!
!!! tip
Textual serve is also useful when developing your app.
If you make changes to your code, simply refresh the browser to update.
## Live editing
If you combine the `run` command with the `--dev` switch your app will run in *development mode*.