It turned out that secure_filename not friendly with non-ascii characters:

 from werkzeug.utils import secure_filename file_name = "Шаблон описание commits дизайнера.txt" filename = secure_filename(file_name) print(filename) # commits_.txt 

The function is used when uploading a file to the server via an html page using flask . On the page through the input, the file is indicated and sent. And secure_filename used to secure the server on behalf of the file. Web server will be located on Windows.

I would like to know what are the analogues of this function. I do not exclude that you have to write your analog.

  • secure_filename() behaves as documented (in fact, the characters allowed for portable POSIX file names are used: [A-Za-z_.-] ). If you have other requirements, then explicitly specify them. What is the context: where does the name come from, how is it used later? What are file systems, OS? Want to treat: 'ё.txt' and 'ё.txt' as identical names or different? Want to support non-BMP characters, surrogate pairs? - jfs
  • @jfs, I completed the question - gil9red 6:01
  • ... and added a link to which he took an example of downloading files through flask - gil9red
  • It is not clear how the name is used further. If you simplify, what's stopping you from simply using randomly generated names? (and the name provided by the user to the database to write as is) - jfs
  • Probably, I will do just that - for the files I will generate random names, and in the base enter the generated name and the one that the user came up with - gil9red

0