After learning about how to create a module that is accessible from global site-package and creating a virtual environment venv for a specific project. Let us dive in to learn FLASK

Flask provides a collection of modules that help you build server-side web applications. It’s technically a micro web framework, in that it provides the minimum set of technologies needed for this task. This means Flask is not as feature-full as some of its competitors — such as Django, the mother of all Python web frameworks — but it is small, lightweight, and easy to use.

Lets install Flask — Yes we all know how to install a lib in python, lets get our hands dirty.

This command connects to the PyPI website, then downloads and installs the Flask module and four other modules Flask depends on Werkzeug, MarkupSafe, Jinja2, and itsdangerous.

As I have already installed it says Requirement already satisfied but for you, the first install should end in Successfully installed Jinja2–2.8 MarkupSafe-0.23 Werkzeug-0.15 flask-1.1.2 itsdangerous-0.24

We are done installing FLASK. Let’s see if that works.

Running hello_flask.py in the terminal would result as below:

Don’t bother about hello_flask.py script for now just copy the URL http://127.0.0.1:5000/ paste and run it in your browser.

Yes, it’s a nice message from your first Flask application.

“Hello world from Flask!!!”

It was good to see FLASK saying me a HELLO, but now it’s time to move on.

We are now going to create an endpoint on the root URL and will serve it using a new function.

As it is already explained how we can create a module and install it in site-package for global use.

This is the module that we are going to use in our function to serve out the new endpoint.

Here, We have imported the mymodule, if you are seeing an error after importing mymodule please don’t forget to install in site-package.

Now, running hello_flask.py in the terminal would result us giving a URL http://127.0.0.1:5000/, We had this before now just add a endpoint to this http://127.0.0.1:5000/modulecall and call this URl from the browser we have a better message from our web app this time.

“Well testing the the module Mr. Ankit”

Cool enough to leave you here with your first hands-on with FLASK.

Will catch up soon rendering some HTML.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store