A simple example project on how to use the flask-ligand library.
Project description
A simple example project on how to use the flask-ligand library. This example project is based on the example from the flask-smorest project. (Which is a core library that flask-ligand is built upon)
Quick Start Guide
Follow the instructions below to start exploring this example project!
Prerequisites
Python 3.10+
Docker (with Compose V2)
Clone Repo
$ git clone git@github.com:cowofevil/flask-ligand-example.git
Make Targets
Execute the following command to get a full list of make targets:
$ make help
Setup Python Environment
Create a Python virtual environment:
$ mkvirtualenv -p py310 flask-ligand-example
Setup develop environment:
$ make develop-venv
Setup git pre-commit hooks:
$ make setup-pre-commit
Verify that environment is ready for development:
$ make test-tox
Setup Docker Environment
The included docker environment used for integration testing can also be used for exploring the example project as well!
Setup the Docker environment:
$ make setup-integration
Verify that the Docker environment is ready:
$ make check-integration
(Optionally) Execute the integration tests:
$ make test-integration
Explore with SwaggerUI Docs
This example project has all the bells and whistles enabled for the flask-ligand library which can be explored by using the included SwaggerUI documentation. Follow the instructions below to start start running a local Flask server to serve the SwaggerUI documentation.
Generate a ‘.env’ file to configure Flask server to use the included Docker environment:
$ make gen-local-env-file
Initialize the database:
$ make setup-db
Generate a JWT access token with admin rights for accessing the included example project endpoints:
$ make gen-admin-access-token
Start the local Flask server:
$ make run
Open a browser and navigate to ‘http://localhost:5000/apidocs’.
Click the ‘Authorize’ button and paste in the JWT access token you created previously.
Now go ahead and start playing around with the API!
Access Keycloak Admin Console
If you would like to make changes to the Keycloak IAM clients to explore authentication then you can access the admin console by navigating to ‘http://localhost:8080/admin/master/console/’. The admin credentials can be found in the ‘docker/env_files/integration.env/’ file.
Flask-Migrate Auto-generation
For Flask-Migrate to work well when auto-generating migration scripts it is critical that the script.py.mako template in the migrations folder include an import for sqlalchemy_utils. This project already has the template updated, but if you are using the flask-ligand library without copying this example project, then it is necessary you make the appropriate update to the script.py.mako template before using Flask-Migrate.
Resources
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flask-ligand-example-0.5.2.tar.gz
.
File metadata
- Download URL: flask-ligand-example-0.5.2.tar.gz
- Upload date:
- Size: 53.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.30.0 requests-toolbelt/1.0.0 urllib3/2.0.2 tqdm/4.65.0 importlib-metadata/6.6.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c25e474d013d4036512b0d8a326887c976ca4ac1913f66b5d42d89f2e60e99c2 |
|
MD5 | bd39ae536021731180db9c274d6dafeb |
|
BLAKE2b-256 | 695a6db8b8389ea3889c9883f019349bf4c22f8b352f221309b36c5c91200a95 |
File details
Details for the file flask_ligand_example-0.5.2-py2.py3-none-any.whl
.
File metadata
- Download URL: flask_ligand_example-0.5.2-py2.py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.30.0 requests-toolbelt/1.0.0 urllib3/2.0.2 tqdm/4.65.0 importlib-metadata/6.6.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c064fa180de0a11a4a79f4cd10e731bae0e583bbec35b8898472bc6ead5d56d |
|
MD5 | c3e94226ffd997b19854a4909a8662bb |
|
BLAKE2b-256 | dc58c439a29f610e2db5b8341e3ff4301f8c858164f7a47087d521a5f3f994d7 |