Friday, September 16, 2022

Flask Tutorial for beginners - Part 3

INSTALLING PYTHON/FLASK

For Windows users, you can get a copy of Python at Python's official website at Python's Official Website

For most other operating systems (Mac and Linux), Python comes pre-installed though you may need to get an upgrade without removing the existing installed version.

But getting and installing Python is not in scope for this tutorial, we'll start with installing Flask.

To install Flask, the best option is to open a command prompt (or terminal) and type in the following command:

pip install flask

That's all

To check if flask is installed, in the same command prompt, launch python and type in the following at the Python prompt:

from flask import Flask

You should see output similar to the diagram below.


In the diagram above you note that the version of flask installed on my machine is version 3.7.3 and the computer is running Linux.

When I typed in from flask import Flask. Note that the Python prompt returns without any error messages.

If you see any error messages it means that Flask is not installed and you can try and run the pip command again. Please note that on some systems, you may have to switch your account to an administrator account in order to install Flask.

PYTHON/FLASK ONLINE

If you don't want to install Python/Flask on your computer, there are excellent resources online. One of the best is Pythonanywhere. You can sign up for a free account which is more than enough for the examples we will be working through.

Now that Flask is installed, let's write our first Python/Flask application. 










No comments:

Post a Comment