Gice

Technology and General Blog

The Flask is a free Python-created micro net-based framework. We have made use of the termed microframework for the reason that you don’t want added libraries and equipment to operate with it.

It is quite simple for rookies to build maintainable, scalable, and secure net apps utilizing the Flask. Contrary to Django (a different python framework), a consumer doesn’t require ORM and other functionality from the 3rd-occasion libraries.

The advantage of applying the Flask is, it has built-in python offers to give additional functionalities to the flask application.

How to Set up Flask on Ubuntu 20.04

To get Flask software, stick to the shown actions:t

Using the apt bundle supervisor, the set up system of a Flask on Ubuntu 20.04 is quite easy. What you need to have to do initially is update all the offers of the Ubuntu system by the command:

We do not need to install python on the technique as it is a created-in offer on the Ubuntu equipment. To make sure its existence, run the talked about command in the terminal:

Go to the next command to develop a virtual setting of python via the python3-venv bundle as given:

$ sudo apt install python3-venv

Make a new directory for the Flask application and applying the down below-described command to navigate it:

$ mkdir flask_dir && cd flask_dir

The moment you developed the directory, head in excess of and run the upcoming command to develop a virtual setting inside of the “flask_dir” directory:

The “venv” is the identify of the virtual natural environment listing. To put in the Flask, we want to activate this directory:

$ supply venv/bin/activate

Immediately after the comprehensive setup of setting up python and developing directories, now you can put in the Flask framework with all of its elements by way of the Python package manager “pip”:

To verify, execute the presented command:

$ python -m flask –model

How to build a Flask software

Let’s produce a straightforward Flask application to demonstrate how it will work:

In the “flask directory (we created above), publish a very simple program in a text editor and help you save it with the “.py” extension.

For case in point, in my program, I made a file named “test.py” in the “flask_dir” listing and publish a tiny plan in it:

Now, open up the terminal and run the following commands to run the flask software on the server:

Open the server hyperlink, and you will get the outcome:

Summary

The Flask is a python written world-wide-web framework intended to establish world wide web purposes. The guidebook has revealed how to put in the Flask framework and its usage. We made the virtual natural environment 1st and set up the Flask framework, then wrote an example code to check out how the Flask software works. As opposed to Django, you do not need to have any specific resource or libraries to get the job done with flask.

Leave a Reply

Your email address will not be published. Required fields are marked *