Flask is a free, open-source micro web framework for Python. It is built on Werkzeug and uses Jinja2 as its template engine. Unlike Django, Flask does not include an ORM, form validation, or authentication out of the box. Instead, it relies on extensions to add functionality. Extensions are Python packages that plug into your Flask app to provide things like database access, login handling, or form validation. Because Flask gives you a bare skeleton to build on, there is no magic happening behind the scenes, every piece of your application is explicit and visible in your code.
This guide walks you through installing Flask on Ubuntu 18.04 inside a Python virtual environment, then creates and runs a minimal web application to confirm everything works.
Prerequisite: You need sudo access.
Ubuntu 18.04 ships with Python 3.6 by default. Verify it is available:
bashpython3 -V
Install the python3-venv package to enable virtual environment support:
bashsudo apt install python3-venv
Create a project directory and navigate into it:
bashmkdir my_flask_appcd my_flask_app
Create the virtual environment inside the project directory:
bashpython3 -m venv venv
This creates a venv subdirectory containing a private copy of Python, pip, and the standard library. Any packages installed here stay isolated and do not affect other Python projects on the machine. You can create as many virtual environments as you need — one per project — and each one maintains its own independent set of packages.
Activate the virtual environment:
bashsource venv/bin/activate
Your shell prompt changes to (venv) to show the environment is active. Inside a virtual environment, use pip instead of pip3 and python instead of python3.
Install Flask:
bashpip install Flask
Verify the installation:
bashpython -m flask --version
Open a text editor and create a file named hello.py inside the project directory:
pythonfrom flask import Flaskapp = Flask(__name__)@app.route('/')def hello_world(): return 'Hello World!' Here is what each part does:
Flask class from the flask package__name__ tells Flask where to find templates and static files@app.route('/'): registers hello_world as the handler for the root URLhello_world(): returns the string sent to the browser when someone visits /Set the FLASK_APP environment variable so Flask knows which file to load, then start the server:
bashexport FLASK_APP=hello.pyflask run
Flask starts a local development server at http://127.0.0.1:5000/. Open that URL in a browser to see the Hello World! message.
<strong>Note:</strong> The Flask development server is for local testing only. For production, use a WSGI server like <strong>Gunicorn</strong> or <strong>uWSGI</strong> behind an Nginx reverse proxy.
Stop the server with CTRL+C. When you are done working, deactivate the virtual environment:
bashdeactivate
To resume work later, navigate back to the project folder and run source venv/bin/activate again.
Flask is now installed on your Ubuntu 18.04 machine. Explore the official Flask documentation to learn about blueprints, request handling, Jinja2 templates, and database integration with Flask-SQLAlchemy. Leave a comment below if you run into any issues.
PHP 8.5 is included in Ubuntu 26.04's default repositories and is the recommended version for…
Ubuntu 26.04 LTS "Resolute Raccoon" arrived on April 23, 2026 with Linux kernel 7.0, GNOME 50,…
Kubernetes is the standard platform for running containerized workloads across multiple servers with self-healing, rolling…
Ubuntu 26.04 LTS "Resolute Raccoon" was released on April 23, 2026 with Linux kernel 7.0, GNOME desktop, and standard security support until April 2031. A clean install gives you a known-good starting point on new hardware, when replacing another operating system, or when an upgrade path is not practical. This guide walks through how to install Ubuntu 26.04: downloading and verifying the ISO, writing a bootable USB drive, completing the installer, and doing the initial setup after the first boot. Before you start: You need a USB drive with at least 12 GB of free space. Back up any existing data on the target machine — the installer can erase the entire disk. Install Ubuntu 26.04: Download the ISO…
The correct timezone affects more than the clock on your screen. It drives cron job scheduling, systemd timer execution, log file timestamps, database record timing, and SSL certificate validity checks. A mismatched timezone can cause scheduled jobs to fire at the wrong hour and make log timestamps impossible to match with real-world events. This guide shows how to change timezone on Ubuntu using the timedatectl command (the recommended approach for servers and remote machines) and through the graphical Date & Time settings on desktop systems. The steps apply to all current Ubuntu releases including 24.04 and 26.04. <strong>Prerequisite:</strong> Only the root user or a user with sudo access can change the system timezone. Check the Current Timezone Before You Change It Run timedatectl with no arguments to see the active timezone and clock status: bashtimedatectl Sample output: Local…
Atom is a free, open-source, cross-platform code editor developed by GitHub. Built on Electron, it uses…