No description
  • Dockerfile 42.6%
  • Python 32.2%
  • HTML 25.2%
Find a file
2026-05-02 18:42:13 +02:00
templates Initial commit: Simple Flask Airplane Picker example 2026-05-02 18:40:45 +02:00
.gitignore Initial commit: Simple Flask Airplane Picker example 2026-05-02 18:40:45 +02:00
airplanes.json Initial commit: Simple Flask Airplane Picker example 2026-05-02 18:40:45 +02:00
app.py Initial commit: Simple Flask Airplane Picker example 2026-05-02 18:40:45 +02:00
Dockerfile Add Dockerfile and expand README with alternative setup instructions 2026-05-02 18:41:50 +02:00
README.md Explain Docker in README 2026-05-02 18:42:13 +02:00
requirements.txt Initial commit: Simple Flask Airplane Picker example 2026-05-02 18:40:45 +02:00

Simple Flask Airplane Picker

A very simple web application for beginners to see how Python, Flask, and JSON data work together.

How it works

The app has three main parts:

  1. airplanes.json: Our "database". It's just a text file with a list of airplanes and their types.
  2. app.py: The "brain". It reads the list, picks a random one, and tells the browser what to show.
  3. templates/index.html: The "face". It defines how the information should look in your browser.

Getting Started

1. Set up the environment

We use uv in this example, but you can use standard Python tools, Conda, or any other manager.

uv venv
uv pip install -r requirements.txt

Using standard Python venv

python -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txt

Using Conda

conda create -n airplane-picker python=3.11
conda activate airplane-picker
pip install -r requirements.txt

2. Run the application

Activate your environment (if not already) and start the server:

# Run the app
python app.py

3. See the results

Open your browser and go to: http://127.0.0.1:5000

Deployment & Docker

What is Docker?

Think of Docker as a way to package your entire application (the code, the Python version, and all the libraries) into a single "container."

  • Without Docker: You have to make sure the person running your code has the right version of Python and all the libraries installed manually.
  • With Docker: You give them the container, and it runs exactly the same way on their machine as it does on yours. This is why it's great for hosting on the web!

If you want to host this on platforms like Vercel, Render, or Fly.io, we have included a Dockerfile.

To run locally with Docker:

docker build -t airplane-picker .
docker run -p 5000:5000 -e PORT=5000 airplane-picker

Learning Points

  • Flask is a "micro" web framework. It handles the "routing" (deciding what happens when you visit /).
  • Jinja2 is the template engine (the {{ airplane.name }} syntax) that lets Python talk to HTML.
  • JSON is a common way to store and transfer data.