#References https://www.imaginarycloud.com/blog/flask-python/
Flask demo project with auto generated Swagger documentation. Refer to the IC Blog Post to have a detailed explanation of this demo.
Clone the repo to your local machine by running the command:
git clone https://github.com/pedromartinho/flask_demo
You must have python installed in your machine. The code presented will run in python3. If you want to use python2 and/or are following this procedure in a Windows machine please refer to the instructions presented in the Flask installation guide
After that, go into the folder with the project and create a virtual environment with the following command:
python3 -m venv venv
Active the the respective environment by running:
. venv/bin/activate
Note: It might be important to specify the environment you are considering when running this code in your IDE.
Install the project's dependencies with the following command. This will consider the packages detailed in the requirements.txt file. This is done using [pip] (https://pypi.org/) (Python package installer):
pip install -r requirements.txt
Before running the application set the Flask environment variables:
export FLASK_APP=main.py
export FLASK_ENV=development
Run Flask... RUN!!
flask run
The application has three different "modules" presented in detail in the IC Blog Post
Basic endpoints for demo purposes:
- https://flask-ic.herokuapp.com/basic_api/hello_world | GET method
- https://flask-ic.herokuapp.com/basic_api/entities | GET and POST methods
- https://flask-ic.herokuapp.com/basic_api/entities/<entity_id> | GET, PUT and DELETE methods
Example of a Jinja template rendering with dynamic content change based on query params top and bottom. This allows you to create your own Business Cat meme:
Endpoints created based on the Flask-RESTPlus suggested structure and documentation. All the endpoints previously created are presented with a better structure inside the blueprints folder. This is achieved with the usage of Flask-RESTPlus extension You can check the generated documentation by referring to this link: https://flask-ic.herokuapp.com/documented_api/doc