- Clean Code
- Statistics Processing needs to be separated from http server in order to be able to run on a different machine. This could be an improvement to performance and load balancing in case of intensive use of http server.
- Authentication need to be implemented in order to improve security
- Accepting zip files can be a security risk !?
- ...
- Script in utils/scripts/
- Pandas code in statistics/
- Request/Response processment in swagger_server/controllers
- zip file (and unziped) and generated histogram image will be saved (in runtime) in cache/
This server was generated by the swagger-codegen project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub. This is an example of building a swagger-enabled Flask server.
This example uses the Connexion library on top of Flask.
Python 3.5.2+
To run the server, please execute the following from the root directory:
pip3 install -r requirements.txt
python3 -m swagger_server
and open your browser to here:
http://localhost:8080/challenge/ui/
Your Swagger definition lives here:
http://localhost:8080/challenge/swagger.json
To launch the integration tests, use tox:
sudo pip install tox
tox
To run the server on a Docker container, please execute the following from the root directory:
# building the image
docker build -t swagger_server .
# starting up a container
docker run -p 8080:8080 swagger_serverNote: histogram is returned in base64 and saved as an image in cache/
endpoints:
- localhost/challenge/ -> can be average, smallest, biggest and histogram
Request Example 1:
curl -X 'POST' 'http://192.168.1.64:8080/challenge/average' -H 'accept: application/json' -H 'Content-Type: multipart/form-data' -F 'zfile=@test.zip;type=application/zip'
Response Example 1:
["averageSize", {"mean": 8.0}]
Request Example 2:
curl -X 'POST' 'http://192.168.1.64:8080/challenge/biggest' -H 'accept: application/json' -H 'Content-Type: multipart/form-data' -F 'zfile=@test.zip;type=application/zip'
Response Example 2:
[\"biggestFile\", {\"name\": \"/home/rafael/Downloads/python-pandas-bash-challenge/cache/uploads/test\", \"size\": 20}]