Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions.

In this guide, we will explain how to install Flask on CentOS 7.

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can easily deploy your own cloud servers.

Once you have signed up, log into your Cloudwafer Client Area with the password provided in your mail and deploy your Cloudwafer cloud server.

Updating System Packages
It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:

sudo yum update

Step 1: Install Python 3 and venv
Install Python 3.6 from the Software Collections (SCL) repositories as the default version of Python on CentOS 7 is Python 2.7.5. SCL allows you to install newer versions of python 3.x alongside the default python v2.7.5. To enable SCL, install the CentOS SCL release file which is included in the CentOS extras repository by issuing the command below:

sudo yum install centos-release-scl

Installing-Flask-on-CentOS-7-1

Once the repository is enabled install Python 3.6 with the command below:

sudo yum install rh-python36

Step 2: Creating a Virtual Environment
Start by navigating to the directory where you would like to store your Python 3 virtual environments. It can be your home directory or any other directory where your user has read and write permissions.

To access Python 3.6 you need to launch a new shell instance using the scl tool:

scl enable rh-python36 bash

Create a new directory for your Flask application and navigate into it:

mkdir cloudwaferlabs_flask_app
cd cloudwaferlabs_flask_app

Issue the command below to create a new virtual environment:

python3 -m venv venv

The directory venv created will contain a copy of the Python binary, the Pip package manager, the standard Python library and other supporting files.

Next, activate the virtual environment using the activate script by issuing the command below:

source venv/bin/activate

Step 3: Install Flask
After activating the virtual environment, use the Python package manager pip to install Flask by issuing the command below:

pip install Flask

Read more on Flask from the official Documentation and the Quickstart