To start project, run:
docker-compose up
The API will then be available at http://127.0.0.1:5000
- Checking that file is actually an image is basically unpossible. Problem is that extention says nothing about the contents of a file. When I wrote code to download files without
json
extension I tried to to do that but there are no 100% garantees. Therefore there is no error handling on that part because no one can know if this is an error or not. - When downloading
json
files encoded image has to be in the first key. (There has to be some kind of a system because there is no way to distinguish string from base64 encoded image.) - Images that are decoded from json will have
png
extention, though it can be easily changed. (Maybe one can put an extention tojson
file, for application to know which extension to add to the name of the decoded file, but currently is seem to contradict the task.) - As there isn't a lot of logic here, tests are called unit tests (here named by function) if they actually do something independent of flask like encoding to base64. Also if all of the logic is done in flask it is also a unit test (e.g. downloading regular images). If flask is needed only as an interface between logic and user than it is called integrational test.
- Tests are situated in
tests
directory. - Images and json for tesing purposes are situated in
tests/files_for_tesing
directory. If oe is testing unit tests that only do something specific (e.g. download from url) their output will go totests\upload
directory. - Currently all files are downloaded to
upload
directory, so after Docker container stops working all downloaded files are lost. I can add volumes or database, but currently it seems to be out of scope of this task. - Graceful shutdown is implemented.
docker stop
will work as needed. - Travis CI is used as a continuous integration tool.