Update README.md

This commit is contained in:
Will McGugan
2023-08-22 10:55:59 +01:00
committed by GitHub
parent 44e75c3a0c
commit 6f3941e6d2

View File

@@ -60,3 +60,74 @@ When you serve a terminal in this way it will generate a new random URL, but not
Textual Web can serve multiple [Textual](https://github.com/Textualize/textual) apps and terminals (as many as you like).
Do do this, we need to create a TOML file.
To demonstrate this, install Textual and check out the repository.
Navigate to the examples directory and add the following file:
```toml
[app.Calculator]
command = "python calculator.py"
[app."Code Browser"]
command = "python code_browser.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:
```bash
textual-web --config serve.toml
```
You should now get 3 links, one for each of the secions in the configuration:
<img width="1145" alt="Screenshot 2023-08-22 at 10 37 59" src="https://github.com/Textualize/textual-web/assets/554369/8e6e8248-7d77-4d77-af03-70f1a9147bf3">
Click any of the links to serve the respective app:
<img width="1131" alt="Screenshot 2023-08-22 at 10 42 25" src="https://github.com/Textualize/textual-web/assets/554369/fb4b6ad2-3431-41bc-b7b3-5cfd81e1eab8">
### Terminal configutation
You can also add a terminal(s) to the configuration file, in a similar way.
```toml
[terminal.Terminal]
```
## Accounts
In previous examples, the URLS have 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:
```bash
textual-web --signup
```
This will bring up a dialog in your terminal that looks something like this:
<img width="1145" alt="Screenshot 2023-08-22 at 10 49 54" src="https://github.com/Textualize/textual-web/assets/554369/539fd8bc-c218-48b9-a00f-31855e7a4306">
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:
```toml
[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:
```bash
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.