Python REST API with Flask - Part 2 - File upload and static file serve - Source Dexter

Join the Sourcedexter Community  Community to talk about AI, machine learning, blockchain and more!


  1. Emerson Lara
    October 17, 2017 @ 4:09 pm

    I don’t know why, but the API cant find the “test.html” file on html folder…
    Look the log error: – – [17/Oct/2017 08:36:20] “GET /html/test.html HTTP/1.1” 404 –
    Have you any tip?


    • admin
      October 17, 2017 @ 10:00 pm

      There was an error in the code, lt;path:path:gt; should have been something else. I have made the changes. You can make this change as well and I think your issue will be solved.


  2. Anders
    May 8, 2018 @ 6:40 pm

    Using Flask 1.0.2, I get an error when sending a file with Postman.

    The console prints: – – [08/May/2018 15:09:37] “POST /upload HTTP/1.1″ 200 –
    ImmutableMultiDict([(”, )])

    But in Postman the Body response is “No file found”


    • Anders
      May 8, 2018 @ 6:42 pm

      Some characters are deleted, maybe this comment field doesn’t like the “greater-than” symbol.
      ImmutableMultiDict([(”, FileStorage: u’dropoffs.jpg’ (‘image/jpeg’))])


  3. dashkov
    February 15, 2019 @ 12:13 am

    from flask import Flask, request, send_from_directory

    # set the “static” directory as the static folder.
    # this will ensure that all the static files are under one folder
    app = Flask(__name__, static_url_path=’/static’)

    # serving some static html files
    def send_html(path):
    return send_from_directory(‘static’, path)

    if __name__ == “__main__”:

    this code returns this error

    404 Not Found
    Not Found
    The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.


Leave a Reply

%d bloggers like this: