Hello, friends. In this post, you will learn how to install Flask on Fedora. In theory, we should have no problem completing the post, but as always, we’ll offer you some help.
Introduction
Flask is a “micro” Framework written in Python and developed to simplify and make easier the creation of Web Applications under the MVC pattern.
Don’t be fooled by the “micro” because this doesn’t mean that you can’t do great things with it, but rather because it is minimalistic, and you can add as many components as you want and need.
Let’s go for it.
Install Flask on Fedora
The process is simple but requires a few steps to be executed.
First, open the terminal and make sure the system is up-to-date.
sudo dnf update
Python should be installed by default, but it is always better to be certain.
sudo dnf install python3
So, you need to install PIP which is the Python package manager that we will use for this post.
sudo dnf install python3-pip
Now check the version of PIP
pip3 --version
pip 22.3.1 from /usr/lib/python3.11/site-packages/pip (python 3.11)
Before you use it, update it
pip3 install -U pip
Create a Python virtual environment for Flask
The next step is to create a virtual environment for Flask.
python3 -m venv flaskenv
You can replace flaskenv
with any name you want.
The next step is to activate it
source flaskenv/bin/activate
You will notice a change in the terminal prompt.
Get Flask
Now you can install Flask on the system. This is done by running the following command:
pip3 install flask
This will start the download and installation of Flask.
With Flask installed, you can then do a hello-world
to demonstrate that everything is in order.
Create the file in question
nano ~/app.py
And add the following:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello, welcome to unixcop'
if __name__ == '__main__':
app.run()
Save the changes and now raise the test server.
python3 ~/app.py
Now open your favorite web browser and go to http://localhost:5000
and you will see the app running.
Conclusion
Flask is one of the most important frameworks available today. It combines Python with the simplicity of being very flexible and suitable for many projects.