Flask Introduction
Flask is a Python library for building websites. A website built with Flask answers requests with pages.
Check that Flask is installed
This code asks for the installed Flask version. The answer starts with 3.
from importlib.metadata import version
print(version("flask").split(".")[0])Example
from importlib.metadata import version
print(version("flask").split(".")[0])
parts = version("flask").split(".")
print(len(parts))Key points
- Flask is a small web framework for Python.
- A web framework is a library that handles web requests.
- A request is a message from a browser asking for a page.
- Flask takes a request and returns a page as the answer.
- Use Flask to build sites, tools, and small web apps.
In this example, version reads the installed Flask version. The opening print shows 3, the first part. The version is then split into parts at each dot. The closing print shows the count of parts, 3.
Note
Plain Python ships without Flask, so install it first.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What is Flask?