'Why is the image still not appearing?
So it appears that some images are being shown but others nada. Why?
Code` app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024
#Image Handleing
ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg'])
def allowed_file(filename):
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@app.route('/Detect')
def upload_form():
return render_template('upload_image.html',title='Update', year=datetime.now().year)
@app.route('/Detect', methods=['POST'])
def upload_image():
if 'file' not in request.files:
flash('No file part')
return redirect(request.url)
file = request.files['file']
if file.filename == '':
flash('No image selected for uploading')
return redirect(request.url)
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
#print('upload_image filename: ' + filename)
flash('Image successfully uploaded and displayed below')
return render_template('upload_image.html', filename=filename,title='Detection', year=datetime.now().year)
else:
flash('Allowed image types are -> png, jpg, jpeg, gif')
return redirect(request.url)
@app.route('/display/<filename>')
def display_image(filename):
#print('display_image filename: ' + filename)
return redirect(url_for('upload_image', filename='/uploads/' + filename), code=301)
<!--
<h1 class="jumbotron">Image Classification</h1>
<br><br>
<div class="row">
<div class="col-auto col-md-4 mx-auto">
<form class="form-horizontal" action="/Detect" method="post" enctype="multipart/form-data">
<div class="mb-3">
<label for="" class="form-label"></label>
<input type="file" name="file" id="" class="form-control" placeholder=".png, .jpeg etc..." aria-describedby="helpId">
<small id="helpId" class="text-muted">Upload Your Image</small>
</div>
<br>
<input type="submit" value="Upload" class="btn btn-success">
</form>
</div>
<div class = "col-md-4 col-auto mx-auto">
{% if filename %}
<img src="{{ url_for('display_image', filename=filename) }}" />
{% endif %}
</div>
-->
`
In Addition it doesn't even give me a 404 on the terminal it just gives me 200 and maybe 304 as an insult. here are image of that Mock Me, Mocks Me again...
Please tell me I am doin something wrong or is it a bug?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
