2023-10-17 18:24:43 +02:00
|
|
|
# zrok Pastebin
|
2023-10-18 19:28:29 +02:00
|
|
|
|
2023-10-17 18:24:43 +02:00
|
|
|
This example shows the use of the zrok SDK spinning up a simple pastebin command.
|
|
|
|
|
2023-10-18 19:28:29 +02:00
|
|
|
## Self-hosting Setup :wrench:
|
|
|
|
|
|
|
|
You don't need this section if you're using hosted zrok from NetFoundry (https://api.zrok.io/).
|
|
|
|
|
|
|
|
Refer to the [setup guide](../../../docs/guides/self-hosting/self_hosting_guide.md) for details on setting up your zrok
|
|
|
|
environment if you're self-hosting zrok.
|
2023-10-17 18:24:43 +02:00
|
|
|
|
|
|
|
### Install Python Requirements
|
2023-10-18 19:28:29 +02:00
|
|
|
|
|
|
|
The zrok SDK requires Python 3.10 or later.
|
|
|
|
|
2023-10-17 18:24:43 +02:00
|
|
|
If you haven't already installed them, you'll need the dependent libraries used in the examples.
|
2023-10-18 19:28:29 +02:00
|
|
|
|
|
|
|
```bash
|
|
|
|
pip install -r ./sdk/python/examples/requirements.txt
|
|
|
|
```
|
2023-10-17 18:24:43 +02:00
|
|
|
|
|
|
|
## Running the Example :arrow_forward:
|
2023-10-18 19:28:29 +02:00
|
|
|
|
|
|
|
This example contains a `copyto` server portion and `pastefrom` client portion.
|
2023-10-17 18:24:43 +02:00
|
|
|
|
|
|
|
### copyto
|
2023-10-18 19:28:29 +02:00
|
|
|
|
2023-10-17 18:24:43 +02:00
|
|
|
The server portion expects to get data you want to send via stdin. It can be evoked by:
|
2023-10-18 19:28:29 +02:00
|
|
|
|
|
|
|
```bash
|
2023-10-17 18:24:43 +02:00
|
|
|
echo "this is a cool test" | python pastebin.py copyto
|
|
|
|
```
|
2023-10-18 19:28:29 +02:00
|
|
|
|
2023-10-17 18:24:43 +02:00
|
|
|
You should see some helpful info printed out to your terminal:
|
2023-10-18 19:28:29 +02:00
|
|
|
|
|
|
|
```bash
|
2023-10-17 18:24:43 +02:00
|
|
|
access your pastebin using 'pastebin.py pastefrom vp0xgmknvisu'
|
|
|
|
```
|
2023-10-18 19:28:29 +02:00
|
|
|
|
2023-10-17 18:24:43 +02:00
|
|
|
The last token in that line is your share token. We'll use that in the pastefrom command to access our data.
|
|
|
|
|
|
|
|
### pastefrom
|
2023-10-18 19:28:29 +02:00
|
|
|
|
2023-10-17 18:24:43 +02:00
|
|
|
The `pastefrom` client expects the share token as an argument.
|
|
|
|
If we envoke it using the same token as above:
|
2023-10-18 19:28:29 +02:00
|
|
|
|
|
|
|
```bash
|
2023-10-17 18:24:43 +02:00
|
|
|
python pastebin.py pastefrom vp0xgmknvisu
|
|
|
|
```
|
2023-10-18 19:28:29 +02:00
|
|
|
|
2023-10-17 18:24:43 +02:00
|
|
|
we see the data we had piped into the `copyto` server:
|
2023-10-18 19:28:29 +02:00
|
|
|
|
|
|
|
```text
|
2023-10-17 18:24:43 +02:00
|
|
|
this is a cool test
|
2023-10-18 19:28:29 +02:00
|
|
|
```
|