fix: Add image before checking files

This commit is contained in:
Nathan Woodburn 2024-02-25 14:23:45 +11:00
parent ed222714ce
commit 96f7f0fece
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -204,6 +204,7 @@ def site_post():
address = [i for i in address if i['address'] != '']
data['address'] = address
data['image'] = ''
if 'image' in request.files:
if request.files['image'].filename != '' and request.files['image'].filename != None:
# Make sure the file is an image
@ -211,9 +212,7 @@ def site_post():
extension = file.filename.split('.')[-1]
file.save(f'avatars/{i["name"]}.' + extension)
data['image'] = f'{i["name"]}.' + extension
else:
data['image'] = ''
data['image'] = f'{i["name"]}.' + extension
with open(f'sites/{i["name"]}.json', 'w') as file: