Skip to content

Commit

Permalink
add readme, sample.env and instructions for python-dotenv (#370)
Browse files Browse the repository at this point in the history
Co-authored-by: Josip Janzic <[email protected]>
  • Loading branch information
horeaporutiu and janza authored Apr 18, 2024
1 parent 4316387 commit 6d3c81c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/miro-api-python/example/.sample.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MIRO_CLIENT_ID='<your-client-id>'
MIRO_CLIENT_SECRET='<your-client-secret>'
MIRO_REDIRECT_URL='<your-redirect-url>'
58 changes: 58 additions & 0 deletions packages/miro-api-python/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Miro Python client Flask example

This example shows how to use Flask and Miro's Python REST API client library to create a simple web-app running locally
which calls Miro's REST APIs to fetch boards.

## App Demo

https://github.com/miroapp/app-examples/assets/10428517/aea10102-9b67-4976-8f37-855922b4f1cc

## Prerequisites

- Python 3.9 or higher.

## Install dependencies

This example uses `miro_api`, `flask` and `python-dotenv`. You can use either **pip** or **poetry** as follows:

**Using [pip](https://github.com/pypa/pip)**:

```bash
pip install miro_api flask python-dotenv
```

**Using [poetry](https://python-poetry.org/docs/)**:

```bash
poetry add miro_api flask python-dotenv
```

## Configuration

We recommend using a `.env` file to store env variables. Go ahead and open the `.sample.env` file, and then add your variables in.

Once you are done, it should look like this (*it is recommended to use http://localhost:5000*):

```bash
MIRO_CLIENT_ID='123456789'
MIRO_CLIENT_SECRET='abcdefghijklmnopqrstuvwxyz'
MIRO_REDIRECT_URL='http://localhost:5000'
```

Ensure you rename the file `.env` and then save it.

### Run the app

Run `flask --app app run` to start the dev server.

Go to `localhost:5000` in your browser.

Install the app on a team, and then you should see a list of all of the boards for that team.

### Reference

- [Miro Python library reference](https://miroapp.github.io/api-clients/python/)

### Examples

See an example of implementing a simple server using Flask library in the [example](https://github.com/miroapp/api-clients/tree/main/packages/miro-api-python/example) directory.
4 changes: 4 additions & 0 deletions packages/miro-api-python/example/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
from miro_api import Miro
from miro_api.storage import Storage

from dotenv import load_dotenv

load_dotenv()

app = Flask(__name__)

app.secret_key = b'very_random_secret'
Expand Down

0 comments on commit 6d3c81c

Please sign in to comment.