A basic Flask API that implements CRUD operations using Flask-RESTX and stores data in a PostgreSQL server. Interaction with the database is done using SQLAlchemy. Flask-RESTX also allows for the creation of swagger documentation for the API.
Copy the .env-template
file, and rename the copy .env
. This file will store
environent variables for configuring the API (these values will be assigned in
the sections below).
Create a new virtual environment named .venv
, activate it with source .venv/bin/activate
, and install dependencies with _install_requirements
Specify the postgres configuration such as IP/domain, port, user, password, etc.
in .env
.
Once all environment varaibles have been set, run source .env
in order to
export all environment variables
-
_activate_environment
- exports environment varaibles in
.env
and activates the virtual environment - Important: must be run like so:
. ./_activate-environment
- exports environment varaibles in
-
_export_requirements
- used to export current dependencies to
requirements.txt
- used to export current dependencies to
-
_gunicorn_start
- starts gunicorn using config file
-
_install_requirements
- used to install all dependencies from
requirements.txt
- should be run inside the virtual environment
- used to install all dependencies from
-
_start_dev_server
- starts the api