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-09-04T02:54:05Z by Kevin Foong
In this blog post we will be exploring the Quasar QUploader component in order to upload photos and how to handle this in the backend via Flask. I assume you already have some basic knowledge about Vue, Quasar and some Flask.

Read more ...
Tags:
flask
quasar
Posted on 2020-08-30T05:16:57Z by Kevin Foong
Make sure you keep any sensitive information in environment variables such as database passwords and API keys. In Vue you can use the dotenv
package and in Quasar you can use the quasar-dotenv
package which is wrapper around dotenv
.
cd to your project folder and install quasar-dotenv
npm install quasar-dotenv
Now create a .env
file in your project root and add any variables. For example:
OW_API_KEY = '002db37bfc6be228c33d416df8a6e917'
GM_API_KEY = 'CIzaTyDL6C63jOmI2KCbysrmRSJ_2DriHfFMqZY'
Read more ...
Tags:
quasar
Posted on 2020-08-27T21:57:32Z by Kevin Foong

Quasar is a Vue framework that makes it easy to build hybrid mobile apps using Cordova. In this introduction I'll provide an overview on how to build a simple Android app. Note that the Quasar website already has quite good documentation on how to get started. Here I will outline my notes and any difficulties I encountered along the way during my own set up. Hopefully this tutorial will help someone get started in developing mobile apps.
I also assume that you already have some Vue knowledge.
Step 1 - Install Quasar CLI and create a project in the folder "myquasar"
npm install -g @quasar/cli
quasar create myquasar
Read more ...
Tags:
Vue
quasar
cordova
android
Posted on 2020-06-13T11:37:25Z by Kevin Foong
In this post we will explore some simple SQLAlchemy statements and compare them to their SQL equivalents. This post is just on using Flask SQLAlchemy to query your database. If you want to know how to model your database please see my other post here. Let's get started!
Let's say we have two tables UserDetails
and Country
in a one to many relationship towards Country
. That is one UserDetails
can only have one Country
. But one Country
can have many UserDetails
. Our models look like this.
UserDetails
class UserDetails(db.Model):
__tablename__ = 'user_details'
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
first_name = db.Column(db.String(50), nullable=False)
last_name = db.Column(db.String(50), nullable=False)
gender_id = db.Column(db.Integer, db.ForeignKey('gender.id'), nullable=False)
dob = db.Column(db.String(10), nullable=False)
country_id = db.Column(db.Integer, db.ForeignKey('country.id'), nullable=False)
state = db.Column(db.String(30), nullable=False)
city = db.Column(db.String(30), nullable=False)
def __repr__(self):
return '<UserDetails {}>'.format(self.first_name)
Read more ...
Tags:
flask
flask-sqlalchemy
database