1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] File uploading in flask and showing error message

Discussão em 'Python' iniciado por Stack, Novembro 26, 2025.

  1. Stack

    Stack Membro Participativo

    I'm implementing an application to process GPS data. In the application users can upload files and those files will be processed in server.

    I need to validate the user uploaded file extension. But the problem is extensions can be change.

    .17o, .11o, .12o, .13o, .14o, .15o, .23o, .54o


    common patterns are

    .*o, .*n, .*obs, .*nav, .nav, .obs


    * is always a 2 Digit number

    This is what I have tried

    ALLOWED_EXTENSIONS = set(["*+'n'" , "*+'o'"])


    How can I change the ALLOWED_EXTENSIONS to accept above mentioned common patterns.

    I have used flask documentation for the upload file reference

    I think I have to change this functions

    def allowed_file(filename):
    return '.' in filename and \
    filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS

    Continue reading...

Compartilhe esta Página