Install Flask on AlmaLinux 9 – Web App Framework for Python

This guide intends to teach you to Install Flask on AlmaLinux 9. As you may know, Flask is a lightweight and flexible web app framework for Python. You can easily use Flask to build and deploy web apps with its features and tools included.

Now you can follow this step-by-step guide to quickly install Flask on the AlmaLinux 9 server.

Step-by-Step Guide To Install Flask on AlmaLinux 9

Before you start your Flask installation, you must log in to your server as a non-root user with sudo privileges. To do this, you can check the Initial Server Setup with AlmaLinux 9.

Also, you must install Python and Pip on your server. To get the latest version, you can check this guide on Installing Python 3.12 on AlmaLinux 9.

Then, follow the steps below to complete this guide.

Step 1 – Use Pip To Install Flask on AlmaLinux 9

First, verify your Python installation on AlmaLinux 9:

python3 --version
Output
Python 3.12.2

Then, verify Pip installation on AlmaLinux 9:

pip3 --version
Output
pip 24.0 from /usr/local/lib/python3.12/site-packages/pip (python 3.12)

Now you can easily use Pip to install Flask on your server:

sudo pip3 install flask

Once your installation is completed, you will get the following output:

Output
Successfully installed Jinja2-3.1.3 MarkupSafe-2.1.5 Werkzeug-3.0.1 blinker-1.7.0 click-8.1.7 flask-3.0.2 itsdangerous-2.1.2

Step 2 – Create a Test App with Flask

At this point, to check Flask is working correctly, we want to create a test app on AlmaLinux 9. To do this, create a project directory and switch to it with the commands below:

# mkdir flask_app
# cd flask_app

Then, use your favorite text editor like Vi editor or Nano editor to create a Flask File:

sudo vi hello.py

Add the following content to the file:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello, Flask is installed successfully!'

if __name__ == '__main__':
    app.run(debug=True)

When you are finished save and close the file.

Now you can run your Flask app with the following command on AlmaLinux 9:

python3 hello.py

You should see an output indicating that the Flask development server is running. Open a web browser and navigate to http://127.0.0.1:5000 to see your Flask application in action.

Run Flask App with Python

For more information, you can check the official website.

Conclusion

At this point, you have learned to install Flask on AlmaLinux 9 by using the Python pip and create a test app for it to see if it is working correctly. Hope you enjoy it.

Also, you may like to read the following articles:

Configure Network Bridge on AlmaLinux 9

Reset MySQL Root Password on AlmaLinux / Rocky Linux

HAproxy Load Balancing on AlmaLinux 9

Top SSH Security Tips on AlmaLinux 9

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!