What is Flask?



When learning a web framework, a developer must understand the types of web frameworks there are and what they are. One such is Flask.

Flask is a micro web framework in python which is used to create web applications easily.

It was developed by Armin Ronacher, who was also the leader of a team of python enthusiasts known as POCCO.
Flask is based on the werkzeug WSGI(web server gateway interface) toolkit and jinja2 template, these both were also developed by POCCO.


Flask is mostly used to create lightweight websites(or web applications), this is the reason that flask is often called a microframework.
Basically in the tech industry flask is very famous because it is considered very easy and scalable.
Also, you don’t need to practice that much coding to create a simple web app with the help of a flask.
The default host used by flask is a local host and its default port number is 5000.


Being called a microframework doesn’t mean that you need to put your code in just a single file, in flask you can use different files of code for larger programs.
To start working with flask you need to install flask on your pc with the help of a package manager known as pip.
The command for installation is “pip install flask”.


The next main thing to know in the flask web framework are templates and that these templates help you to reuse.
 Templates help you to divide the business and presentation logic.

Let us take an example to understand templates more deeply,
Imagine that you are creating two or three web applications in which the context of each one of them is different but their basic outlook or outline is the same.
In these kinds of situations, the templates become very handy as you don’t need to write the outlook, again and again, you can just use the same template by using render_template.

A template is just a file that contains HTML code inside of it(HTML is the standard language for the web ).
Flask and most modern web applications nowadays use a technique that is known as routing. This technique helps people to remember URLs. 
In flask, we can do routing by using the command “@app.route()”.



The next important thing to know in flask are static files.
In static files, we keep CSS, JavaScript, and image files. These are the files that support web display.


Now next we are gonna talk about cookies,
cookies are text files that are stored on a user’s computer to track data.
The cookies are used to track data on the user’s computer, that data is further used for better user experience and web stats.
In flask, the Request object is the one that contains the properties of cookies.
Request object is a kind of dictionary for all cookie variables and their corresponding values.

The next thing to talk about is session data,
session data is a time interval at which the user logs on and out of the server.
Unlike cookies, the session data is temporarily stored on the server.

As we can see that flask provides us with many features like cookies, session, templates, static files, and so on but these aren’t enough to form a full-fledged web app, so in addition to these functions flask also provides us with extensions.

Flask extensions provide you with some more functionality.
There are many flask extensions that we can use but these are the highly used ones

1. Flask Mail: It used to create or send mails
2. Flask SQL Alchemy: It adds SQL support
3. Flask WTF: It used to create WT forms

We can simply import and use all these extensions.
Flask has become one of the most popular web frameworks of python amongst python enthusiasts and has the second most stars on GitHub among the python web framework due to its easy-to-use nature and its scalability.



If you wish to read more of these kinds of posts check out our website   https://collegeintegral.blogspot.com/

Post a Comment

Previous Post Next Post