FlaskTool Site

airport-distance-python-tutorial — Flask Tool Template

By apiverve

A Flask-based airport distance calculator template that looks up the distance and estimated flight time between two airports using three-letter IATA codes, offering both a web interface and a command-line script, with one-click deployment to Vercel.

Explore the design

Compare the page layouts and mobile experience. Open any screenshot for a closer look.

1 previews
Author preview
Author-provided preview

Preview provided in the project README.

One original preview is available. Open the full image to inspect the design.

Screenshots show visual appearance; interactive behavior may differ.

Recorded 2026-10-01View source

What stands out

A quick read of the recorded project description.

01

Enter two three-letter IATA airport codes to get distance (miles/kilometers) and estimated flight time

02

Provides both a Flask web interface and a python distance.py command-line tool

03

API key is kept on the server; the browser never touches the key

04

Supports one-click deployment to Vercel, with app.py converted to a Python function and public/ served by CDN

05

The page uses plain HTML/CSS/JavaScript with no framework and no build step

Template Details

This template is a Python + Flask airport distance calculator. Enter two three-letter IATA airport codes to get the distance between them (in miles and kilometers) and the estimated flight time. The project provides both a web app and a command-line tool: the web version has public/index.html call the GET /api/distance endpoint, while the command-line version runs via python distance.py JFK LAX. Both share the same .env configuration.

The server-side logic is concentrated in app.py and apiverve.py: it first validates that both codes are 3 letters, then calls APIVerve's Airport Distance API with the API key. The API key stays on the server and is never sent to the browser. The page renders based on the actual returned fields; under the free plan, some fields are omitted when empty.

Before use, you need to register with APIVerve yourself and configure APIVERVE_API_KEY. The built-in rate limit is stored in memory and is not shared across serverless instances; the README recommends switching to shared storage (such as Upstash Redis), adding your own login, or calling the route only from your own backend in production. The project is MIT licensed, depends only on flask and requests, and uses plain HTML/CSS/JavaScript with no build step.

FlaskUtility site

Is it right for your project?

Use Cases

  • Display the distance between two airports on a flight search or booking page
  • Estimate trip mileage or carbon emission reference data for travel reports
  • Serve as a sample project for learning Flask routing and third-party API calls
  • Quickly look up the distance between two airport codes via the command line

Suitable For

  • Developers who need airport distance and flight time lookup functionality
  • Beginners who want to learn API integration and Vercel deployment through a small Flask project
  • Lightweight scenarios that need quick IATA code distance lookups on a web page or command line

Getting started & customization

Use these recorded setup notes alongside the repository instructions for your chosen version.

  1. 1

    Register with APIVerve to get an API key and write it to APIVERVE_API_KEY in .env

  2. 2

    Local run: create a virtual environment, pip install -r requirements.txt, then run python app.py and visit http://localhost:3000

  3. 3

    Command-line usage: python distance.py JFK LAX; without arguments it prompts for input

  4. 4

    When deploying to Vercel, provide APIVERVE_API_KEY in the environment variables

  5. 5

    The built-in rate limit is 10 requests per visitor per minute and stored in memory; before production use, switch to shared storage or add access control

Read repository instructions

License & source material

Usage conditions & limitations

Free to use · keep license notice

This entry covers the free version under the MIT license in the public repository; the free scope applies to that version's code and does not mean external services or third-party assets are free.

Must comply with when using

  • You may freely use, modify, commercialize, and distribute this version's code.
  • When distributing copies or substantial portions of the code, retain the original author's copyright notice and the full MIT license notice.
  • The code is provided as is; warranties and limitations of liability are governed by the original license and applicable law.

Additional costs & items to verify

  • Using this template requires registering with APIVerve and configuring APIVERVE_API_KEY; otherwise neither the web page nor the command line can call the airport distance API.
  • Under the free plan, some response fields (such as certain distance or flight time data) return empty values; full fields require a paid plan.
  • The built-in rate limit is 10 requests per visitor per minute and is suitable only for demonstration purposes.
  • The rate limit is stored in memory and is not shared across serverless instances; production environments need shared storage.
  • For production deployment, add your own login authentication; otherwise any visitor will consume your API key quota.
  • For production, migrate the rate limit to shared storage such as Upstash Redis, which may incur external service fees.
  • You can also call the route only from your own backend to avoid publicly exposing your API key quota.
  • The project materials mention an optional paid version or features; this entry covers only the public free code and does not include paid upgrades.
  • Demo images, fonts, icons, and other third-party assets must be checked against their respective licenses and cannot be judged solely by the code's MIT license.
  • External services such as domains, hosting, databases, payments, or AI may incur separate charges.
View Original Text Basis

Permission is hereby granted, free of charge

Original License Text

This template needs an APIVerve API key.

Original README

Some response fields are for paid plans and come back empty on the free plan.

Original README

Each visitor can make 10 requests a minute, which is fine for a demo.

Original README

The limit is kept in memory, so it isn't shared between serverless instances.

Original README

Put the page behind your own sign-in, or

Original README

Move the limit to a shared store such as [Upstash Redis](https://upstash.com/), or

Original README

Call the route only from your own backend.

Original README
https://github.com/apiverve/airport-distance-python-tutorial/blob/main/LICENSEhttps://github.com/apiverve/airport-distance-python-tutorial/blob/main/README.md

Compiled by DeepSeek based on repository license and README ·2026-10-01. Results only cover the materials read; dependencies, images, fonts, and subsequent term changes are subject to their respective original texts.

Project checks & description sources

Template Information

Source platforms
GitHub
Documentation and maintenance reference score
More documented · 80 / 100
Technologies
Flask
Website type
Tool Site
How this score is calculated

Our heuristic uses license records (up to 30), a demo link (12), a preview (10), stars (15), recorded maintenance (15), description completeness (8), feature records (5) and classification data (5). It is not a code, security or performance test, or a Google score. A link does not establish tested functionality.

What to verify for this project

Repository update recorded
2026-09-19
Screenshot last checked
2026-10-01

A demo link is listed. Check it with your own content and viewport sizes; its presence does not confirm that forms, authentication or payments work.

The catalog identifies Flask as the primary stack. Check the actual dependency manifest and lockfile for versions and hosting requirements. These notes use recorded metadata, not a code audit or a deployment test.

Use a selection guide →

How this description was prepared

AI-assisted description based on catalog records and repository material. Repository authors are not automatically the reviewers of this description.

Automatically checked against source and license rules; no manual editorial review.

Inspect the recorded source material

SHA-256: c605ed2ea506a29bae323c5c60fd1840307d10a4e797011c7397479110c8d2a0

2026-10-01T02:44:49.593Z

Source file / repository
# Airport Distance Calculator | APIVerve Template

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Python](https://img.shields.io/badge/Python-3.12-3776AB)](requirements.txt) [![Flask](https://img.shields.io/badge/Flask-3-000000)](app.py)
[![APIVerve | Airport Distance](https://img.shields.io/badge/APIVerve-Airport_Distance-purple)](https://apiverve.com/marketplace/airportdistance?utm_source=github&utm_medium=template&utm_campaign=airport-distance-python-tutorial)

The distance and flight time between any two airports, from their 3-letter codes. A web app you can deploy, and a command-line tool.

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fapiverve%2Fairport-distance-python-tutorial&project-name=airport-distance&repository-name=airport-distance&env=APIVERVE_API_KEY&envDescription=Your%20APIVerve%20API%20key.%20Free%20to%20create%2C%20no%20card%20needed.&envLink=https%3A%2F%2Fdashboard.apiverve.com%2Fsignup%3Fapi%3Dairportdistance%26utm_source%3Dvercel%26utm_medium%3Dtemplate%26utm_campaign%3Dairport-distance-python-tutorial)

![Airport Distance Calculator showing JFK to LAX](https://raw.githubusercontent.com/apiverve/airport-distance-python-tutorial/main/screenshot.png)

---

### Get your free API key

This template needs an APIVerve API key. **[Sign up free](https://dashboard.apiverve.com/signup?api=airportdistance&utm_source=github&utm_medium=template&utm_campaign=airport-distance-python-tutorial)**, no credit card required.

---

## Deploy in one click

Click **Deploy with Vercel** above. Vercel copies this repo to your GitHub account, asks for your `APIVERVE_API_KEY`, and gives you a live URL about a minute later.

## Run it locally

1. **Clone the repository**
   ```bash
   git clone https://github.com/apiverve/airport-distance-python-tutorial.git
   cd airport-distance-python-tutorial
   ```

2. **Install the dependencies**
   ```bash
   python -m venv .venv
   source .venv/bin/activate      # Windows: .venv\Scripts\activate
   pip install -r requirements.txt
   ```

3. **Add your API key**
   ```bash
   cp .env.example .env
   ```
   Then open `.env` and set `APIVERVE_API_KEY`.

4. **Start it**
   ```bash
   python app.py
   ```

5. **Open** `http://localhost:3000`

`python app.py` serves the page and the API route together, so you don't need the Vercel CLI.

## Use it from the command line

```bash
python distance.py JFK LAX
```

Run it with no arguments to be prompted instead. It reads the same `.env` as the web app.

## How it works

1. The page (`public/index.html`) calls `GET /api/distance?from=JFK&to=LAX`.
2. `app.py` checks both codes are 3 letters, then calls Airport Distance. Your API key stays on the server and never reaches the browser.
3. The page shows the result.

```
├── app.py             # Flask app: the /api/distance route, which holds your key
├── apiverve.py        # Shared by app.py and distance.py: the key, the APIVerve call, the rate limit
├── distance.py        # The command-line version
├── public/            # The page: index.html, app.js, ui.js, style.css
├── requirements.txt   # flask, requests
├── .python-version    # 3.12, for Vercel
└── .env.example       # Copy to .env and add your key
```

### The API call

```python
res = requests.get(
    'https://api.apiverve.com/v1/airportdistance',
    params={'iata1': 'JFK', 'iata2': 'LAX'},
    headers={'x-api-key': os.environ['APIVERVE_API_KEY']},
)
data = res.json()['data']
# data['distanceMiles'], data['distanceKm'], data['estimatedFlightTime']
```

Some response fields are for paid plans and come back empty on the free plan. The page shows whatever it gets and leaves the rest out, so it works on every plan.

## Before you share your URL

Once deployed, anyone who finds your URL can use it on your API key. Each visitor can make 10 requests a minute, which is fine for a demo. The limit is kept in memory, so it isn't shared between serverless instances. For production:

- Put the page behind your own sign-in, or
- Move the limit to a shared store such as [Upstash Redis](https://upstash.com/), or
- Call the route only from your own backend.

## Ideas to extend it

- Show the distance on a flight search or booking page
- Estimate travel emissions for trip reports
- Look up the airports themselves with [Airports Lookup](https://apiverve.com/marketplace/airports?utm_source=github&utm_medium=template&utm_campaign=airport-distance-python-tutorial)

## API reference

- [Airport Distance](https://apiverve.com/marketplace/airportdistance?utm_source=github&utm_medium=template&utm_campaign=airport-distance-python-tutorial): `GET https://api.apiverve.com/v1/airportdistance?iata1=&iata2=`
- [Full documentation](https://docs.apiverve.com?utm_source=github&utm_medium=template&utm_campaign=airport-distance-python-tutorial)

## Tech stack

- **Flask** for the API route, with **requests** to call APIVerve (Python 3.12)
- Plain HTML, CSS and JavaScript for the page: no framework and no build step
- Deploys to Vercel as-is: `app.py` becomes a Python function and `public/` is served from the CDN

## License

MIT. See [LICENSE](LICENSE).
Report a correction

Explore similar templates

Compare previews and descriptions within the same stack and category.