HomeCareerAn introduction Flask Python |Top Ways to Install Flask?

An introduction Flask Python |Top Ways to Install Flask?

As we know python is the programming language that makes use of web frameworks. These frameworks help to create a number of web applications, websites, APIs, and desktop applications. So what actually a framework means? The framework is a library of code and has modules. These modules are highly beneficial for developers in making of web applications meant to be scalable, maintainable, and reliable. The framework usually helps in providing reusable code and extensions. Python provides various frameworks as Flask, Tornado, Pyramid, and Django.

As we know that there are several libraries in python. You can install the Flask package from the Python Package Index (PPI).  Flask is basically a micro web application framework that is written in python language. you can use it for making web applications, HTTP request management, and template rendering. By micro web application, it means that it is not a full-stack framework. It also lacks most of the functionality as compared to a full-stack web application.

But even though this micro web framework is lightweight it is easy to work with or making any project and it is much more powerful to do a lot of things. The term micro refers to making the core part simple but rather extensible. Using Flask it is easy to find mistakes and fix errors in any of the projects as compared to the full framework. you can use Flask to create its own products also. Many big companies like Netflix, LinkedIn, Pinterest, Twilio, Uber, and Dropbox use Flask.

Why use the Flask

Now the next question arises that if we were already having a Django framework that is famous enough to make web apps and APIs due to its set project structure and inbuilt tools then why it needs to shift to Flask. Flask is more useful as compared to Django because it is like an empty canvas to create flask applications and it does not have any dependencies or project layout. Flask can provide suggestions for libraries and tools so that you can use them for development purposes.

Coming to the history of Flask, it was developed as of April fool’s joke by Armin Ronacher who leads a python group named Pocco in 2010. It was not that much popular at that time of development but in the Python Developers survey 2018 Flask got most of the votes and by January 2020 it got its actual popularity through GitHub.  So flask is ultimately based on Werkzeug WSGI toolkit and Jinja2 engine that are pocco projects.

  • Werkzeug- it is used by the flask framework as one of its bases for implementing requests, response objects, and other utility functions.
  • Jinja2- It is a templating engine used in python to combine it with some data source and obtain dynamic web pages.
  • WSGI- It is Web server Gateway Interface. For web application development it is used as a standard for python.

Some important features of flask are as follows

  • Flask has its own development server to run any application and debugger that refreshes the server when we made changes to code. The server is only meant to be used for development and not for deployment.
  • Flask supports Jinja2 that is designer-friendly and allows secure sandboxed execution. Templating  Jinja allows easy exchange of data between the front end and backend. So it is a kind of Bridge in the flask.
  • Flask is based on the werkzeug WSGI tool that provides a web server gateway interface to make communication between the web server and web application.
  • It supports cookies and sessions so that it can make internet browsing experience better.
  • Flask also provided Extensive documentation with examples so that we can use it in case of help.
  • Flask class allows extensions also like database library, upload handling, form validation, and open authentication technologies.
  • Easy boilerplate code for app making up and running makes flask a good web framework choice as compared to Django.

Comparison of Flask and Django

 A web developer is having a number of options to choose a web framework while using python as a server-side programming language. He can either choose web frameworks which are having a lot of features and tools to develop a complex web application or a micro framework that can be used for making simple web applications.

Django and Flask both are having their own popularity among developers but Django is Full stack web framework and Flask is lightweight and extensible. Django also lacks some robust features provided by python and based on a batteries-included approach. While flask is based on two pocco projects Werkzeug WSGI and Jinja2 template. On the one hand, Werkzeug WSGI provides communication between web server and application, and on other hand, the Jinja2 template helps in making dynamic web pages.

Few important points to understand about Django and Flask

  • Being Full stack python web framework Django makes it easy to perform user authentication, URL routing, and database structure migration-related tasks while the simplicity of the flask helps in keeping the web application core part simple and extensible.
  • Django provides ready to use admin framework but that facility is not available in the flask.
  • Flask is based on the Jinja2 template that is inspired by the Django template.
  • Django is also providing a built-in bootstrapping tool to start web applications but flask does not.
  • Flask does not provide built-in ORM for database support while Django does.

So the conclusion said both of these web frameworks are equally popular but has pros and cons too. So it is up to the developer to keep in mind the requirement of the client project to make better use of technology. The Django features provide the facility to make large projects that are having complexity while flask facilitates simple web applications by giving required functionality only. However, the flask is simple, flexible, and easily controllable.

It allows you to implement things the way you like. On the other hand, Django facilitates its user with an admin panel, the interface of the database or you can say it gives an inclusive experience to the developer. Flask usually focuses the learning and experience but Django considers the final product. Overall both of these frameworks are getting popular.

Steps to install flask on our environment

There are different ways to install flask on your system environment but in this article, I am describing only two ways.

Way No.1

  • First of all download the latest python and pip version. It is just simple Google the word python and open the official python website python.org and download python latest version according to your system requires either the 32-bit executable installer or 64 bit for windows, Mac, or other platforms.
Flask installation Step no.1
  • After that process is really simple and straight forward. Just double click the .exe file of python and you can install it on your system.
Flask installation Step no.2
  • Search CMD in the search bar of your desktop then presses enter on finding it.
  • Change Directory using command cd desktop and make new directory using command mkdir myfolder (folder name). Soon a new folder will be created to your desktop instantly.
  • Type cd myfolder to enter in it. You can make another subdirectory within myfolder if you want.
  • The next step is creating a virtual environment, activating it, and installing a flask using the following steps as mentioned in the screenshot.
  • cd desktop- To enter a desktop environment you have to use this command.
  • mkdir myfolder- this command helps in creating a folder using CMD.
  • cd myfolder- This command allows the user to enter in a folder named myfolder.
  • python  –version – This command tells the user about the version of python installed in your computer system.
  • py –m venv env – This command creates a virtual environment in which your Django or flask code will work.
  • env\Scripts\activate- This step activates the virtual environment.
  • pip install flask- This command installs the flask in your system using CMD.
Flask installation Step no.3
  • Now create a web.py file inside that folder.

Way No.2

  • Create a folder on your desktop. Give it the name Flask. For all coding try to download Visual Studio Code from code.visualstudio.com.
  • Open this folder using visual studio code and create a file named as app.py in it where the app is the name of the file and .py extension tells the visual studio code that it is a python file.
Flask installation wayno. 2 Step no.1
  • Next step is to install flask and this could be done using PIP package to install libraries.
  • Open terminal in Visual studio code and write down command pip install flask.
Flask installation wayno. 2 Step no.2
  • Your downloading will be start within seconds.

So that is all about your Flask installation in simpler ways. I would recommend you, people, to use flask for the creation of social networks, blogs, news clones of hackers, and client sites. Flask provides developers everything say its great features so that developers can make useful applications and websites. But to make some heavy or bulky application you have to choose other frameworks.

I also have mentioned in this article how flask is better than Django. But even if you are having confusion regarding which framework is best for your use I will suggest Flask. The flask will help you to understand different pieces of code easily. I hope that the above-mentioned information will be very useful for you. Please give your views about flask also.

Anjali Saini
Anjali Saini
A hardworking person, always adventurous about learning new things. Aiming to develop new skills and passion for computer technology.


Please enter your comment!
Please enter your name here

Most Popular