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>