Reputation: 91
I have a Flask app running inside Docker container. My app takes the path of a CSV file as input, processes it, and gives some results.
While creating the container I stored a CSV file inside the container itself to test the code. And now when everything is working fine I have to pass this CSV file from outside.
This is because for every API call there will be different CSV file.
Please note that the CSV file will be passed by end-user so it can't be anywhere on the system when we start the container. It will be received after running the container.
How can I provide this CSV file to my application?
Upvotes: 0
Views: 458
Reputation: 136968
My app takes the path of a CSV file as input
It shouldn't take a path to a file. Your users won't have access to the server's filesystem, and your server doesn't have access to your clients' filesystem.
Instead, it should take a file payload in an HTTP request:
- A
<form>
tag is marked withenctype=multipart/form-data
and an<input type=file>
is placed in that form- The application accesses the file from the
files
dictionary on the request object.- use the
save()
method of the file to save the file permanently somewhere on the filesystem.
Upvotes: 4