Installing Flask on Linux Mint 21
The main significance of using Flask is that it comes with built-in Python packages which some extra functionality to this framework, to install it in Linux Mint just go through the steps given below:
Step 1: By default, the Python 3 is installed on almost every Linux distribution but just to be sure let’s check the version of python 3 installed on Linux Mint using:
Step 2: Next install the Python virtual environment and pip:
Step 3: Create a directory in which you will save all your work and move to it using change directory command:
Step 4: Now create flask environment in the created directory and then activate this environment using:
Step 5: Next, install the Flask framework using pip package manager:
Step 6: Next, check the version of Flask installed to see if it is installed correctly using:
Using Flask on Linux Mint 21
To demonstrate the use of Flask, let’s create a Python program and run it. Just go through the subsequent steps:
Step 1: First create a Python file in which the code will be written using:
Step 2: Now enter the code in the Python file and once you are done with writing the code save the file and then close it:
app = Flask(__name__)
@app.route('/')
def my_flask_application():
return 'Welcome to LinuxHint'
Step 3: Now it’s time to export the application and for that use:
<img class="aligncenter wp-image-265702 size-full" src="https://linuxhint.com/wp-content/uploads/2022/12/install-flask-linux-mint-09.png" alt="" width="936" height="204" />
<strong>Step 4: </strong>After that run the flask application and it will give the IP address along with the port number:
[cc lang="text" width="100%" height="100%" escaped="true" theme="blackboard" nowrap="0"]
$ flask run
Step 5: Next run the python file by using the IP address along with the port number in your Linux Mint web browser:
So, this is how one can install and use the Flask on Linux Mint 21.
If you no longer need this framework then uninstall it using:
Conclusion
If you are looking for a Python framework for web application development then Flask is the best Python framework for the users. To install the Flask on a Linux Mint system one needs to install the application using the default package manager.