title: Python Flask - receive image as post
body: <p>I'm having trouble receiving an image from a form on my flask python server. </p>
  
  <p>Here's the code of the html form:</p>
  
  <pre><code>&lt;form action="http://localhost:85/upload" method="POST" enctype="multipart/form-data"&gt;
      Select image to upload:
      &lt;input type="file" name="myImage" id="fileToUpload"&gt;
      &lt;input type="submit" value="Upload Image" name="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here's the code of the server</p>
  
  <pre><code>from flask import Flask, request
  
  app = Flask(__name__)
  
  @app.route("/")
  def main():
      return("Welcome!")
  
  @app.route('/upload')
  def upload():
      try:
          # check if the post request has the file part
          file = request.files['myImage']
          return("Image uploaded")
          print("Image uploaded")
      except Exception as err:
          print("Error occurred")
          print(err)
          return("Error, image not received.")
  
  if __name__ == "__main__":
      app.run(debug=True, host="0.0.0.0", port=85)
  </code></pre>
  
  <p>Here's the output of the console when I submit the form: </p>
  
  <pre><code>"POST /upload HTTP/1.1" 405 -
  </code></pre>
  
  <p>Essentially, just shows that site can't be reached. When I go to the url without submitting image the page works normally.
  I have no clue what I'm doing wrong. All help is appreciated. </p>