Skip to content

Latest commit

 

History

History

examples

Examples

To make everything easier, pyenv helps manage multiple Python versions and optionally virtualenvs with pyenv-virtualenv.

No matter if you choose to use pyenv or not, you should create virtual environments for each example you wish to run. Then, you should install the requirements for that example inside the virtual env by running: pip install -r requirements.txt.

The above is required for all examples.

Example for sample-plain using pyenv:

# switch to example directory
cd ./sample-plain
# create the virtual environment using Python 3.7
pyenv virtualenv -p python3.7 sj-ex-plain
# activate the virtual environment
pyenv activate sj-ex-plain
# install dependencies specific to each project
pip install -r requirements.txt
python start_service.py

You can then access users and organizations.

1. sample-plain

Contains a basic implementation of 3 resources: users, teams and organizations using plain Python classes.

Running:

In order to start the service on http://127.0.0.1:8000/, you can run: python start_service.py

2. sample-tortoise-orm

Requires Python > 3.7 to avoid SQL injection bugs in tortoise-orm.

Contains a basic implementation of 3 resources, users, teams and organizations using tortoise-orm with an in memory SQLite database.

Running:

You can start the service on http://127.0.0.1:8000/, by running: python start_service.py

3. sample-sqlalchemy

Contains a basic implementation of 3 resources: users, teams and organizations using sqlalchemy.

Running:

In order to start the service on http://127.0.0.1:8000/, you can run: python start_service.py

Client:

After starting one of the services, you can play around in Postman using the included collection.