Posted on 2020-12-30T06:49:00Z by Kevin Foong


Swagger is a great tool which enables us to document our API structure and allow others to test it out. Here I will provide an overview on how we can set up Swagger on a Flask API project.
We will use the Flask-Swagger-UI library. Note that this library provides Swagger via a blueprint so we will also need to be using blueprints in Flask (which this post will not go through).
Read more ...
Tags:
flask
API
swagger
Posted on 2020-12-29T11:20:11Z by Kevin Foong
I haven't seen many articles on the internet describing how to use Pydantic together with Flask so I thought of providing an overview of what I did to get this to work. For those who don't know, Pydantic is a Python library used to parse and validate data. It is typically used to ensure that data sent to your API enpoints is in the correct format and type.
- First we install a handy library Flask-Pydantic. This library is used to integrate Pydantic with Flask.
pip install Flask-Pydantic
- Next we create Pydantic schema models. These models define the required fields for the endpoint. A model is just a class that inherits from Pydantic's
BaseModel
. I normally have all models in a separate models_schema.py
file.
- Below is an excerpt from my
models_schema.py
file.
Some notes,
Read more ...
Tags:
flask
pydantic
API
Posted on 2020-05-12T09:06:49Z by Kevin Foong
In this blog post I will provide an overview of how to get Flask to serve a Vue Single Page Application (SPA). I assume you already have the prerequisites installed - namely node.js, Vue and Python.
Vue
1. Use Vue to create your project.
vue create myproject
2. In the Vue CLI select "Manually select features"
For a SPA make sure you choose Router. The rest is your preference.

Read more ...
Tags:
flask
Vue
API