Flask python web framework
Introduction
Flask is a free and open source micro web framework written in python. Flask does not require tools or libraries hence it has been classified as a microframework. It allows us to develop lightweight web applications in python. Flask is designed to be quick and easy to get started with, and it has the ability to scale up to complex applications. Now The Flask has become one of the most popular python web frameworks.
Flask provides the suggestion but it won't make many decisions, for example what database to use, and the decisions that it does make are easy to change. It depends on the developer which tools and library he wants to use. The community supports a rich ecosystem of extensions to build a more powerful application and is easy to develop.
Flask was developed by Armin Ronacher who leads an international group of python enthusiasts (Pocco). It has the main two dependencies Werkzeug (WSGI ) and jinja2. The debugging, routing and Web Server Gateway Interface (WSGI) subsystems come from Werkzeug and the template support is provided by jinja2. These two dependencies Werkzeug and jinja2 are authored by the core developers of flask
Werkzeug
Werkzeug is a toolkit for Web server Gateway Interface (WSGI) application that implements requests, response objects, and utility functions. It can be used to build a custom software framework on top of it. It supports python 2.7 and later versions.
WSGI
The Web Server Gateway Interface (WSGI) has been used as a standard for Python web application development. Its specification of a common interface between web servers and web applications.
Jinja2
Jinja2 is a template engine for python programming language which combines a template with a certain data source to render the dynamic web pages.
Why Flask?
Flask is very explicit compared to django and it is easy to learn because it requires less code to implement the web application.
It is Lightweight
It is easy to set up and get in going
It is easy to get started
It is easy to develop and maintain applications.
Getting started with Flask
Required python 2.6 or higher version for the installation of the Flask in the system. To install flask, run this command 'pip install flask' or ‘python -m pip install flask' in the anaconda command prompt. After the installation is successful we can build the flask web application.
How to run a flask project?
Here we created Simple web application project print ‘Hello World!’
This is a simple program of a flask project web application, In this the message “Hello World!” will appear on the web browser page.
Example code :
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello, World!"
if __name__ == '__main__':
app.run()
First save the above code with the .py extension. To run the flask project open the anaconda command prompt and set the path to the folder that will contain the python file of your flask project. Set the flask application and run the file using the following command
“FLASK_APP=file_name.py”
flask run.
After executing the above command Copy link and past it in any web browser.
Now, when you start the server and visit http://127.0.0.1:5000/, you should be able to see the message.
How Codersarts can Help you in Flask?
Codersarts provide:
Flask Assignment help
Flask Error Resolving Help
Mentorship in Flask from Experts
Flask Development Project
If you are looking for any kind of Help in Flask Contact us
Comments