Hey there! Thinking of developing a web application using python? Probably you must be looking for a framework or if you’re not aware, A Framework is a piece of code which makes developers’ life easier. It lets the developer focus on the high-level functionality of the application and handles the low-level functionality by itself by providing some reusable or extensible codes. In this article, I’m going to discuss one such framework, made for creating web applications in python called FLASK.

What is Flask?

According to the official website of Flask, It’s a python micro-framework. By micro, it doesn’t mean that it is less functional or the whole application should fit in one single python file(although we will see that it’s possible). It’s a highly extensible framework with lots of extensions available by the community but the idea is to keep the core simple. By default, Flask doesn’t include functionalities like database abstract layer, form validation, etc. but these can be added by using extensions.

In this article, we’ll see how to get started with Flask, and we will create a very basic book listing application. (Let’s call it Flask_Bookshelf)

Before jumping to the app I’ll first discuss some basic concepts like Installing Python on your computer, creating a virtual environment (recommended for better management of dependencies for your projects) and, Installing Flask. Let’s see them one by one:

Installing Python

You can visit the official website (https://www.python.org/downloads/) of python to download the latest stable release of python installer corresponding to the OS you’re using and install it.

Use python — version to verify if it’s successfully installed or not.

Creating and activating a virtual environment

Virtual Environments are a group of python libraries, one for each project. Working on a virtual environment is recommended because your different projects may need different versions of python or python dependencies and using one version of a library in one project can break the compatibly of some other project.

Note that I’m using python 3 throughout this article which comes up with ‘venv’ module by default for creating virtual environments. But if you are using python 2 you have to install an additional module called ‘virtualenv’ to create a virtual environment. You can check the official documentation of Flask Installation for more details on this.

Steps to follow:

  • Make your project directory. Here I’m naming it flask_bookshelf
$ mkdir flask_bookshelf
  • Change your working directory to the one just created
$ cd flask_bookshelf
  • Create a virtual environment with the name ‘venv’. You can name it whatever you want.
$ python3 -m venv venv

(Notice that it will create a venv directory in the root)

#coding #python3 #flask #framework #python

An Introduction to Flask: A micro-framework
3.20 GEEK