In this Flask article we want to learn How to Install Flask, first of all let’s talk about Flask.
What is Flask?
Flask is lightweight and popular web framework, Using flask you can build web applications quickly and easily using Python. in this article we want to talk about the installation process of Python Flask.
Flask Features
These are some features of Flask Web Framework
Lightweight and Small
- Micro-framework: Flask is often described as a micro-framework because it provides the essential components that you need for building web application but leaves many decisions up to the developer.
- No ORM by Default: Flask doesn’t come with an ORM (Object-Relational Mapping) system by default, It depends on you, for example if you wan to use ORM in your Flask application then you can install a library or extension.
Modular Design
- Blueprints: In Flask you can use something, that is called blueprints, blueprints are very useful for structuring large applications. Blueprints can define routes and handlers, and this makes it easy to organize code logically.
- Extensions: Flask can be extended with different extensions to add functionality such as database integration, form handling, authentication and many more.
Built-in Development Server and Debugger
- Development Server: Flask comes with a built-in development server that provides a fast, easy way to test and debug applications during development.
- Debugger: The interactive debugger and stack tracker helps you in identifying and fixing errors quickly.
Jinja2 Templating
- Template Engine: Flask uses Jinja2 templating engine, which allows for the creation of dynamic HTML pages with template inheritance, macros and filters.
- Sandboxed Execution: Jinja2 ensures that the templates are executed in a sandbox, providing security.
How to Install Flask?
Before that we install Flask, we need t make sure that we have installed Python on our system or not. you can download the latest version of Python from the official website (https://www.python.org/downloads/).
After installation of Python, now open command prompt or terminal and write this command, after that press Enter and wait for the installation to complete.
1 |
pip install Flask |
To verify that Flask is installed correctly, you can create a simple Flask application using Python Flask.
First of all create a new Python file and add this code in the file, i have called Python file name app.py file, but you can call it what ever you want.
1 2 3 4 5 6 7 8 9 10 |
from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "<h1>Welcome to codeloop.org</h1>" if __name__ == "__main__": app.run(debug=True) |
For running this file navigate to the directory where you saved the app.py file, and type the following command to run the application:
1 |
python app.py |
After that go to http://127.0.0.1:5000/, and this will be the result
Subscribe and Get Free Video Courses & Articles in your Email