-1

I am trying to run this app on Flask but I keep getting this error:

Not Found

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

I have tried using other ports and everything else possible but it still comes with that error.

Any help will be greatly appreciated.

upload.py

from flask import Flask, render_template, request
from flask_uploads import UploadSet, configure_uploads, IMAGES

app = Flask(__name__)

photos = UploadSet('photos', IMAGES)

app.config['UPLOADED_PHOTOS_DEST'] = 'static/img'
configure_uploads(app, photos)

@app.route('/upload', methods=['GET', 'POST'])
def upload():
if request.method == 'POST' and 'photo' in request.files:
    filename = photos.save(request.files['photo'])
    return filename
return render_template('upload.html')


if __name__ == '__main__':
app.run(debug=True)

upload.html

<html>
<head>
<title>Upload</title>
 </head>
 <body>
 <form method=POST enctype=multipart/form-data action="{{ url_for('upload')        }}">
<input type=file name=photo>
<input type="submit">
</form>
</body>
</html>
TrebledJ
  • 8,713
  • 7
  • 26
  • 48
Moshi
  • 1
  • 6

1 Answers1

2

You can use

app.run(host='0.0.0.0')

to make the development server visible on your network. Note that you should never make the debugger available in this case, and should never use the development server in production.

davidism
  • 121,510
  • 29
  • 395
  • 339
CrmXao
  • 937
  • 2
  • 16
  • 19
  • I always got some warning about "never using the development server in production". I was only using this for PoCs and initial demos. Could you explain the reason for this warning? – CrmXao Jan 26 '19 at 05:39