Simple file upload and download microservices written in python
298
simple microservices
Your task is to build a simple microservice using the Python Flask framework. This microservice should be responsible for uploading and downloading typical types of files (txt, pdf, png, jpg, etc.).
/upload
/download
We will be looking at understanding of web services fundamentals, including usage of appropriate error response. — You should force a failure condition to demonstrate.
We will also be looking more broadly at Python code structure, layout, and other best practices.
Feel free to incorporate whatever else you feel appropriate and feasible.
Finally, please provide a way to install dependencies and run/test the app.
http://localhost:8000/ will redict to http://localhost:8000/upload
curl -i -X POST -H "Content-Type: multipart/form-data" -F "file=@/path/to/file/sample.pdf" http://localhost:8000/upload
When file upload fails, the error will show and a link to upload will be provided
txt, rtf, doc, docx, xls, xlsx, pdfUpload file using API endpoint http://localhost:8000/upload/your-upload-file-name.ext
curl -i -X POST -H "Content-Type: application/json" --data-binary "@/Users/austinjung/Documents/sample.pdf" http://localhost:8000/upload/my_upload.pdf
You can get all file names using API http://localhost:8000/download
curl -i -X GET -H "Content-Type: application/json" http://localhost:8000/download
[
{
"filename": "Austin-Jung_2019_resume.pdf",
"url": "http://localhost:8000/download/Austin-Jung_2019_resume.pdf"
},
{
"filename": "sample.pdf",
"url": "http://localhost:8000/download/sample.pdf"
}
]
You can download a file using API http://localhost:8000/download/sample.pdf
curl -i -X GET -H "Content-Type: application/json" http://localhost:8000/download/sample.pdf --output sample.pdf
This project repository is https://github.com/austinjung/python-microservices
The project repository is linked with Austin's Docker Cloud
Clone this repository
git clone [email protected]:austinjung/python-microservices.git
In your docker, run the following line.
cd python-microservices
$ docker-compose down && docker-compose up --build -d
cd python-microservices
$ pytest
Content type
Image
Digest
Size
443.7 MB
Last updated
almost 7 years ago
docker pull austinjung/python-microservices