Skip to content

AyhamB/demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

covid-api demo application

Demo application using Flask, Docker, and Pytest

QuickStart

Clone this repo and run

docker-compose build
docker-compose up

Using postman or a browser, make the following GET request http://localhost:5000/ This endpoint will return the location of the output excel file. Here is a sample output

{
    "output_file": "/data/output/37536460-0fe0-11ec-98d1-0242ac140002.csv"
}

Getting Started

This is a dockerized Flask application, you need to have docker and docker-compose installed to run it

Prerequisites

Configuration

The configuration file is located at src/config.py.

INPUT_FILE_NAME

This is the file name of the input excel countries.csv , by default this file is located at /data/input/countries.csv Below are the default configurations

# To maintain context, the countries.csv should be placed inside /data.
# By default the file is /data/input/countries.csv
INPUT_FILE_NAME = '/data/input/countries.csv'

OUTPUT_FOLDER

This is the location where the output excel containing the results will be located at. The output filename is unique per each request and will be returned for each GET request. By default the output folder set to '/data/output/`

# To maintain context the output directory should be placed inside /data.
OUTPUT_FOLDER = '/data/output/'

LOG_FILE

The log file contains all logs for all requests made to the application. At this point the log level is set to info. By default the log file is at '/data/log/demo.log`

# Log file
LOG_FILE = "/data/log/demo.log"

Building the application

From the project root execute

docker-compose build
docker-compose up

This will create the container and run the flask application using port 5000

Running the app

This application has only one endpoint at /. After setting the desired values of /data/input/countries.csv execute the following GET request using either postman or your browser http://localhost:5000/

This endpoint will return the location and filename of the output excel file with the results.

Running unit tests

This app uses pytest. Tests live in /src/tests/unit/. To run the unit tests modify the DockerFile as follows

# To run unit tests - uncomment below
CMD ["pytest"]

# To run unit test - comment out below
#CMD ["flask", "run"]

Then run

docker-compose build
docker-compose up

About

python demo application

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors