In this Python Flask article we want to learn How to install Flask on Python, Flask is lightweight and popular web framework that allows you to build web applications quickly and easily using Python. in this article we want to talk about the installation process of Python 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 the Python, now open the Command Prompt (Windows) or Terminal (MacOS/Linux), and write below 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 geekscoders.com</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
