Flask is a popular microweb framework written in Python. It is lightweight and easy to use, making it a good choice for developing small web applications. It is designed to enable developers to create and scale web apps quickly and easily. It has a small and easy-to-extend core, with sensible defaults to get started quickly.

In this article, we will show you how to install and use Flask on a Fedora system.

Prerequisites

Before you start, make sure that you have the following installed on your system:

  • Python 3: Flask is a Python web framework, so you will need to have Python installed on your system. You can check if you have Python installed by running the following command:
    python3 -V 
    

    If Python is not installed, you can install it by running the following command:

    sudo dnf install python3 
    
  • Pip: pip is the package manager for Python. It is used to install Python packages, such as Flask. You can check if you have pip installed by running the following command:
    pip3 -V 
    

    If pip is not installed, you can install it by running the following command:

    sudo dnf install python3-pip 
    

Installing Flask on Fedora

Once you have Python and pip installed, you can use pip to install Flask. To install Flask, run the following command:

pip3 install Flask 

This will install Flask and all of its dependencies.

Creating a Flask App

Now that you have Flask installed, you can create a simple Flask app. Create a file called app.py and add the following code:

from flask import Flask

app = Flask(__name__)

@app.route(‘/’)

def hello():

    return ‘Hello, World!’

if __name__ == ‘__main__’:

    app.run()

This code creates a simple Flask app that displays a message when you visit the root URL.

Run Your Flask Application

To run the Flask app, open a terminal and navigate to the directory where you saved app.py. Then, run the following command:

python3 app.py 

This will start the Flask development server, and you should see the following output:

Output

* Serving Flask app 'app' * Debug mode: off WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Running on http://127.0.0.1:5000 Press CTRL C to quit

To view the app, open a web browser and go to the URL http://127.0.0.1:5000/. You should see the message “Hello, World!” displayed on the page.

Conclusion

In this article, we showed you how to install and use Flask on a Fedora system. Flask is a lightweight and easy-to-use web framework that is perfect for developing small web applications. With Flask, you can create powerful and dynamic web applications with minimal effort.