No description
- Dockerfile 42.6%
- Python 32.2%
- HTML 25.2%
| templates | ||
| .gitignore | ||
| airplanes.json | ||
| app.py | ||
| Dockerfile | ||
| README.md | ||
| requirements.txt | ||
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:
airplanes.json: Our "database". It's just a text file with a list of airplanes and their types.app.py: The "brain". It reads the list, picks a random one, and tells the browser what to show.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.
Using uv (Recommended)
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.