- Clone the repository
- Download and install poetry
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
- Install dependencies
poetry install
- Run
poetry run flask run --port 8000
The task is to implement an "Archive previewer" HTTP JSON API in python using flask web framework. That API accepts a ZIP file, processes it on the server, and returns results of processing (list of files inside with their sizes) to the user in JSON format. All processing results are saved to the SQLite database. Repository with the project should be hosted on the https://github.com/ and Github Actions should be used for checking code style with pylint and running tests.
The API should accept 2 requests. One request to upload a file and see its uploading results and the second one to see all previously uploaded files. Every uploaded file should be processed only once (and then discarded), data about the file should be saved to an SQLite database. SQLAlchemy should be used as an ORM for accessing data.
-
GET /
This endpoint returns a list of all files that were previously uploaded to the service.Example output:
[ { "id": 1, "file": "test.zip", "content": [ { "path": "a.txt", "size": 3032 }, { "path": "vacation/summer.jpg", "size": 300720 } ] }, { "id": 2, "file": "test2.zip", "content": [{ "path": "let/it/be.exe", "size": 487348 }] } ]
-
Result page
POST /
This endpoint accepts one file as a request body and returns the content of the file. By the end of request processing, the file should not be saved on the server.
Example request:
curl --request POST -F "file=@/path/to/file.zip" http://localhost:8000
Example response:
{ "id": 3, "file": "file.zip", "content": [{ "path": "something.docx", "size": 754678 }] }
Source code should be stored in a public repository on https://github.com/ or in a private one shared with user https://github.com/kumekay
. It's recommended to not only push the final code to the repo, but also make commits during the process.
Project repo should contain .github/workflows
directory with a workflow, that defines 2 jobs: test
and lint
.
During the linting stage, the codebase should be checked using pylint (with any set of rules). Tests should be written using pytest . There should be at least one unit test for a function that processes a zip archive and one integration test that uploads a known zip file and checks the output of the POST /
endpoint.