mirror of
https://github.com/TrentSPalmer/flask_photo_scaling_app.git
synced 2025-04-10 10:32:47 -07:00
fix style app/photo_routes/photo_upload.py
This commit is contained in:
parent
b3f0de046b
commit
13e6f98c5f
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from flask import Blueprint, render_template, redirect, url_for, flash, request, abort
|
from flask import (
|
||||||
|
Blueprint, render_template, redirect, url_for, flash, request, abort
|
||||||
|
)
|
||||||
from app.forms import UploadPhotoForm
|
from app.forms import UploadPhotoForm
|
||||||
from .scripts.process_uploaded_photo import process_uploaded_photo
|
from .scripts.process_uploaded_photo import process_uploaded_photo
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
@ -23,10 +25,20 @@ def photo_upload():
|
|||||||
if filename != '':
|
if filename != '':
|
||||||
import os
|
import os
|
||||||
file_ext = os.path.splitext(filename)[1]
|
file_ext = os.path.splitext(filename)[1]
|
||||||
if file_ext not in ['.jpg', '.png'] or file_ext != validate_image(f.stream):
|
fe = file_ext
|
||||||
|
if fe not in ['.jpg', '.png'] or fe != validate_image(f.stream):
|
||||||
abort(400)
|
abort(400)
|
||||||
f.save(os.path.join(current_app.config['PHOTO_SAVE_PATH'], 'raw_' + filename))
|
f.save(
|
||||||
photo_id = process_uploaded_photo(filename, current_user, current_app.config)
|
os.path.join(
|
||||||
|
current_app.config['PHOTO_SAVE_PATH'],
|
||||||
|
'raw_' + filename,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
photo_id = process_uploaded_photo(
|
||||||
|
filename,
|
||||||
|
current_user,
|
||||||
|
current_app.config,
|
||||||
|
)
|
||||||
print(photo_id)
|
print(photo_id)
|
||||||
flash("Thanks for the new photo!")
|
flash("Thanks for the new photo!")
|
||||||
return(redirect(url_for('p_route.photo', photo_id=photo_id)))
|
return(redirect(url_for('p_route.photo', photo_id=photo_id)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user