Skip to content

Python + Flask + nginx + gunicorn + MongoDB Atlas in the MVC Docker architecture

Notifications You must be signed in to change notification settings

tezzytezzy/restapi-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Objective

Create a scalable Dockerised RESTful API database lookup service of all the Canadian airports (348), which allows data consumer to inquire by either full or partial city name (case-INsensitive) to receive JSON-formatted result.

Each airport carries four (4) element of attributes:

  1. City - Name of the city where an airport is located
  2. Province - Two-alphabet postal abbreviation
  3. IATA_code - Three-alphabet geocode
  4. Rail_service - Flag either 'Y' or 'N'

Design

Docker containers with the followings in the MVC architecture:

nginx - Reverse Proxy Web Server
gunicorn - WSGI Server
Flask - Application Server
MongoDB Atlas - No SQL database hosted on AWS

(Source Abhishek Saurabh)

Use Case

Example 1 (full city name of 'victoria'):

base) to@mx:~/gits/restapi-app$ curl -H "Content-type: application/json" -X GET http://127.0.0.1/city_search -d '{"City":"victoria"}' | python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   271  100   252  100    19   1184     89 --:--:-- --:--:-- --:--:--  1188
[
    {
        "_id": {
            "$oid": "5dedd3ae8b72b91c057fd562"
        },
        "City": "Victoria",
        "Province": "BC",
        "IATA_code": "YWH",
        "Rail_service": "N"
    },
    {
        "_id": {
            "$oid": "5dedd3ae8b72b91c057fd563"
        },
        "City": "Victoria",
        "Province": "BC",
        "IATA_code": "YYJ",
        "Rail_service": "N"
    }
]

Example 2 (partial city name of 'ter'):

(base) to@mx:~/gits/restapi-app$ curl -H "Content-type: application/json" -X GET http://127.0.0.1/city_search -d '{"City":"ter"}' | python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   534  100   520  100    14   2498     67 --:--:-- --:--:-- --:--:--  2512
[
    {
        "_id": {
            "$oid": "5dedd3ae8b72b91c057fd44e"
        },
        "City": "Chesterfield Inlet",
        "Province": "NU",
        "IATA_code": "YCS",
        "Rail_service": "N"
    },
    {
        "_id": {
            "$oid": "5dedd3ae8b72b91c057fd54c"
        },
        "City": "Terrace",
        "Province": "BC",
        "IATA_code": "YXT",
        "Rail_service": "N"
    },
    {
        "_id": {
            "$oid": "5dedd3ae8b72b91c057fd4c5"
        },
        "City": "Lloydminister",
        "Province": "AB",
        "IATA_code": "YLL",
        "Rail_service": "N"
    },
    {
        "_id": {
            "$oid": "5dedd3ae8b72b91c057fd533"
        },
        "City": "Senneterre",
        "Province": "QC",
        "IATA_code": "XFK",
        "Rail_service": "Y"
    }
]

Reference

Airport codes - Canada

About

Python + Flask + nginx + gunicorn + MongoDB Atlas in the MVC Docker architecture

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published