0

My server generates a dataframe upon receiving a request and I want to send it back to the client as a CSV. I have a few questions as this is my first time doing this:

  • If file is saved with same name each time, does this create conflicts for different users? If yes how to make sure each file name is different?
  • How to delete the file once it's sent to client?
  • Can the dataframe be sent without generating files on server? Yet I want the user to receive a CSV when it clicks on download button
mrk
  • 3,061
  • 1
  • 29
  • 34
  • 1
    obviously it will make conflicts in files if they will be in the same directory but you can make some template name + id of the users for example `filename="somename" + user.id` or something like that. – George Imerlishvili Apr 21 '21 at 11:23
  • 1
    There is no need to save the file to the disk, you can send it directly to the client – mousetail Apr 21 '21 at 11:23
  • @mousetail could you elaborate? Provide documentation/code? – mrk Apr 21 '21 at 12:15
  • The entire flask framework is meant to send files to the client. See https://stackoverflow.com/questions/11773348/python-flask-how-to-set-content-type or https://stackoverflow.com/questions/41543951/how-to-change-downloading-name-in-flask – mousetail Apr 21 '21 at 14:40

0 Answers0