mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 11:36:16 +00:00
Follow DeepSource reccommendations
Nolonger binding to the address, by default it is always localhost
This commit is contained in:
parent
6f759bb678
commit
36a7f83db6
7 changed files with 15 additions and 22 deletions
|
@ -104,9 +104,6 @@ def register():
|
|||
db_session.commit()
|
||||
except exc.IntegrityError:
|
||||
return f'User {username} is already registered!'
|
||||
except Exception as err:
|
||||
logging.error('User %s could not be registered: %s', username, err)
|
||||
return 'Something went wrong!'
|
||||
|
||||
logging.info('User %s registered', username)
|
||||
return 'gwa gwa'
|
||||
|
|
|
@ -114,7 +114,7 @@ def delete_image(image_id):
|
|||
|
||||
# Delete file
|
||||
try:
|
||||
os.remove(os.path.join(current_app.config['UPLOAD_FOLDER'],img.file_name))
|
||||
os.remove(os.path.join(current_app.config['UPLOAD_FOLDER'], img.file_name))
|
||||
except FileNotFoundError:
|
||||
logging.warning('File not found: %s, already deleted or never existed', img.file_name)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ Calculate the contrast between two colors
|
|||
"""
|
||||
|
||||
|
||||
def contrast(background, light, dark, threshold = 0.179):
|
||||
def contrast(background, light, dark, threshold=0.179):
|
||||
"""
|
||||
background: tuple of (r, g, b) values
|
||||
light: color to use if the background is light
|
||||
|
|
|
@ -4,7 +4,7 @@ Tools for generating images and thumbnails
|
|||
|
||||
import os
|
||||
import platformdirs
|
||||
from PIL import Image, ImageOps #, ImageFilter
|
||||
from PIL import Image, ImageOps
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
|
||||
|
@ -65,13 +65,13 @@ def generate_thumbnail(file_name, resolution, ext=None):
|
|||
# Save image to cache directory
|
||||
try:
|
||||
image.save(os.path.join(CACHE_PATH, f'{file_name}_{res_x}x{res_y}.{ext}'),
|
||||
icc_profile=image_icc)
|
||||
icc_profile=image_icc)
|
||||
except OSError:
|
||||
# This usually happens when saving a JPEG with an ICC profile,
|
||||
# so we convert to RGB and try again
|
||||
image = image.convert('RGB')
|
||||
image.save(os.path.join(CACHE_PATH, f'{file_name}_{res_x}x{res_y}.{ext}'),
|
||||
icc_profile=image_icc)
|
||||
icc_profile=image_icc)
|
||||
|
||||
# No need to keep the image in memory, learned the hard way
|
||||
image.close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue