We are going to introduce the concept for HTTP clients by using the famous requests Python library.
Your job is to consume 2 APIs:
- The first one returns a list of all airlines and the countries they are from.
- Since country codes are not very descriptive, we are going to use another API that maps country code to country name
Write a Python program that produces the following histogram: country_name: # of airports in it.
Save that histogram to a JSON file.
It should look something like this:
{
"Moldova": 5,
"USA": 555,
...
}Using the simple_http_server.py and SQLAlchemy, make a Flask server that can answer the following question: How many airlines are there in a country?
The server should answer with the following routes:
GET /airlines?country=Bulgaria
GET /airlines?country_code=BG
Some steps that can help you structure your program:
- Make models in SQLAlchemy
- Import the JSON data into SQL database via that models
- Implement a Flask serve with that models & database
- Make the
/airlinesroute answer the question.