/flights-by-country

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Flights by Country

A FastAPI web application that shows incoming flights by country for any airport using the FlightAPI.io API.

Features

  • Search flights by 3-letter airport code (e.g., SIN, LAX)
  • View number of incoming flights grouped by country
  • Clean and responsive UI
  • Real-time flight data from FlightAPI.io

Setup

  1. Clone the repository:
git clone https://github.com/Amanpradhan/flights-by-country
cd flights-by-country
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file in the root directory and add your FlightAPI.io API key:
FLIGHT_API_KEY=your_api_key_here
  1. Run the application:
uvicorn app.main:app --reload
  1. Open your browser and navigate to http://localhost:8000

Usage

  1. Enter a 3-letter airport code (e.g., SIN for Singapore, LAX for Los Angeles)
  2. Click "Search Flights" to view incoming flights grouped by country
  3. Results will be displayed in a table showing countries and their flight counts

API Documentation

The API documentation is automatically generated by FastAPI and can be accessed at:

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

Deployment

This application can be deployed to various platforms:

Render.com

  1. Create a new Web Service
  2. Connect your GitHub repository
  3. Set the build command: pip install -r requirements.txt
  4. Set the start command: uvicorn app.main:app --host 0.0.0.0 --port $PORT
  5. Add your FLIGHT_API_KEY to the environment variables

License

MIT License