mathisme / picture_pixels

This repo is for the programming problem given for the Fetch Rewards MLE Apprenticeship application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

picture_pixels

This repo is for the programming problem given for the Fetch Rewards MLE Apprenticeship application

Files

  • Dockerfile
  • index.html, a basic html file used in conjuction with pixels.js to send a request to the back-end
  • main.py, this contains the FastAPI app
  • picture.py, a class created to store and validate the picture information as well as calculate and return the coordinates of all pixels. Main.py uses this.
  • pixels.js, the javascript file that is used to get the form information from index.html and send the POST request
  • post.png. The image of the FastAPI backed documentation
  • requirements.txt
  • testPicture.py, unit tests for the picture class.

How to run the program

  • Clone this repo to your local computer
  • Build the docker image, docker build -t myimage .
  • Run the container, docker run -d --name mycontainer -p 80:80 myimage
  • You can send a POST request to the backend at http://127.0.0.1/, see documentation image below, or use the index.html file to make a request after inputting the dimensions of the picture and the coordinates of the corner pixels.

Image of Swagger showing a JSON object to send two post with two parameters, dimensions and corners, both strings

Notes/Assumptions

  • From the image below in the problem statement, decimal pixel coordinates are allowed. So when creating pixel coordinates, decimals were allowed.
  • Also from the image below the coordiate (0,0) is in the bottom left. Most images place (0,0) at the top left. I used the coordinate system shown in the image. Also as this seems like Cartesian coordinates, I assume negative values are acceptable for images and so did not test for negative coordinates.

Image of coordinates with decimals

Future Improvements

  • Create a CSS file to better format the front end. I was just interested in getting it to work
  • In the Dockerfile, only move the necessary Python files, not copy all files to the code directory
  • Add more unit tests

About

This repo is for the programming problem given for the Fetch Rewards MLE Apprenticeship application


Languages

Language:Python 82.6%Language:JavaScript 9.7%Language:HTML 5.4%Language:Dockerfile 2.3%