So I have uploaded an image into the uploads folder with flask dropzone and I want to be able to pass it to my makeMeme page so I can then display that image using the html img tag. Here is how I upload my image, and attempt to pass it. However when I run a basic img take and try to reference file I get an error. Here is the Attribute Error I get:
AttributeError: 'NoneType' object has no attribute 'filename'
Here is my main python page.
import os
from flask import Flask, render_template,request, url_for
from flask_dropzone import Dropzone
app = Flask(__name__)
app.secret_key = 'key'
dir_path = os.path.dirname(os.path.realpath(__file__))
app.config.update(
UPLOADED_PATH=os.path.join(dir_path, 'uploads'),
# Flask-Dropzone config:
DROPZONE_ALLOWED_FILE_TYPE='image',
DROPZONE_MAX_FILE_SIZE=3,
DROPZONE_MAX_FILES=20,
DROPZONE_UPLOAD_ON_CLICK=True
)
app.config['DROPZONE_REDIRECT_VIEW'] = 'makeMeme'
dropzone = Dropzone(app)
@app.route('/upload', methods=['POST', 'GET'])
def upload():
if request.method == 'POST':
f = request.files.get('file')
file = f.save(os.path.join(app.config['UPLOADED_PATH'], f.filename))
return render_template('upload.html', file_name = file)
@app.route('/makeMeme', methods=['POST', 'GET'])
def makeMeme():
return render_template("makeMeme.html")