zrok/sdk/python/examples/pastebin
Cam Otts 3e6ab2b39b
Python SDK Update (#523)
* added first iteration decorator for zrok and example flask server

* update requirements. Add context managing for share and access. Updated pastebin example to better cleanup

* setup and sample tweaks

* small linting updates and example changes

* A few small fixes

* fix long description

* Update the ignore file.
Considering moving location of this.

* Added flake8 linting for builds

* use python 3.10

* move setup python to its own block

* added back in the py name

* update changelogs and add readme

---------

Signed-off-by: Cam Otts <otts.cameron@gmail.com>
Co-authored-by: Kenneth Bingham <kenneth.bingham@netfoundry.io>
2024-01-17 10:46:19 -06:00
..
pastebin.py Python SDK Update (#523) 2024-01-17 10:46:19 -06:00
README.md Python SDK Update (#523) 2024-01-17 10:46:19 -06:00
requirements.txt Python SDK Update (#523) 2024-01-17 10:46:19 -06:00

zrok Pastebin

This example shows the use of the zrok SDK spinning up a simple pastebin command.

Self-hosting Setup 🔧

You don't need this section if you're using hosted zrok from NetFoundry (https://api.zrok.io/).

Refer to the setup guide for details on setting up your zrok environment if you're self-hosting zrok.

Install Python Requirements

The zrok SDK requires Python 3.10 or later.

If you haven't already installed them, you'll need the dependent libraries used in the examples.

pip install -r ./sdk/python/examples/requirements.txt

Running the Example ▶️

This example contains a copyto server portion and pastefrom client portion.

copyto

The server portion expects to get data you want to send via stdin. It can be evoked by:

echo "this is a cool test" | python pastebin.py copyto

You should see some helpful info printed out to your terminal:

access your pastebin using 'pastebin.py pastefrom vp0xgmknvisu'

The last token in that line is your share token. We'll use that in the pastefrom command to access our data.

pastefrom

The pastefrom client expects the share token as an argument. If we envoke it using the same token as above:

python pastebin.py pastefrom vp0xgmknvisu

we see the data we had piped into the copyto server:

this is a cool test