A Flask web application providing a browser-based interface to the flight database.
# 1. Install dependencies
pip install flask psycopg2-binary # psycopg2-binary only needed for PostgreSQL
# 2. Run (auto-initializes SQLite DB on first launch)
python app.pyThen open http://localhost:5000 in your browser.
- Dropdown selectors for origin and destination airport codes
- Date range pickers (from / to)
- Submit button
After submitting, displays all matching flights with:
- Flight number
- Departure date
- Origin & destination codes (and full airport names)
- Departure time (GMT)
- Airline name
- Aircraft type
- Duration
Clicking a flight row shows:
- Capacity of the aircraft
- Number of booked seats
- Available seats (capacity − booked)
- Visual occupancy progress bar
- Full passenger manifest with seat numbers
In app.py, replace get_db() with:
import psycopg2, psycopg2.extras
def get_db():
con = psycopg2.connect(
host="localhost", dbname="flights",
user="postgres", password="yourpassword"
)
con.cursor_factory = psycopg2.extras.RealDictCursor
return conThen change all ? placeholders in queries to %s (PostgreSQL style).
Load the schema from flights.sql directly:
psql -U postgres -d flights -f flights.sqlflights_app/
├── app.py # Flask routes
├── db_init.py # SQLite schema + seed data
├── flights.db # Auto-created on first run
├── README.md
└── templates/
├── base.html # Shared layout / nav
├── index.html # (a) Search form
├── results.html# (b) Flight list
└── detail.html # (c) Seat availability
The app is pre-loaded with the data from the homework SQL file:
- 12 airports, 4 aircraft types, 10 flight services
- 12 flight instances across 2025-12-29 to 2025-12-31
- 25 passengers, ~75 bookings
Quick test: Search JFK → LAX, dates 2025-12-29 to 2025-12-31.