The structure is approximately as follows:

The user presses the "Generate Report" button, on the server it is generated in a zip file and must be transferred back to the user. How can this be done in flask or through request request?

The server part is written in using

    2 answers 2

    Do you use nginx ? If yes, then it seems to me that you can save python from uploading the file, when the user requests the server generates an archive and writes it to a specific directory, with a specific name, returns the file name to the client, and in the nginx settings you can assign an alias to the directory, respectively urlu type https://domen.com/you_folder/?file=file_name user can get his file.

    Here is an example of the nginx configuration and more

    Python and zip

    • and another user will be able to get this file? - Igor
    • The appropriateness of this depends on the size of the archive - andreymal
    • Despite how you do it, you can, for example, generate random letters that another user cannot recognize and receive afile - andreymal
    • Yes, nginx is used, can you write in more detail how to add access to the directory? - Sergey
    • Absolutely right, another user will be able to get the file if he knows his name, however if the file name is W123gYeb-yus67+datetime it will be difficult, and yes, it depends on the size of the files, on their number and on the number of users - Igor Lavrynenko

    Here about file transfer

    If we talk about the report, then everything is too individual to give any specifics.

    Form a question about the report and data archiving. What will be contained in the archive, and if more precisely, which files from the archive should be generated using Flask .

    If a csv, xls, pdf file is generated based on data from the database, and there is a lot of data, then it is better to queue such a task.

    • Formed zip from pictures - Sergey
    • @ Sergey, do you already have a code that zip itself generates? If yes, then use one of those methods that I cited by reference to another answer. - Narnik Gamarnik