upload global stocks added

This commit is contained in:
Justin 2023-09-25 22:25:23 +08:00 committed by GitHub
parent 2005623025
commit 5673bebad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2347,6 +2347,36 @@ def upload_file_stocks():
return index() return index()
@app.route('/upload_globalstocks', methods=['POST'])
def upload_file_globalstocks():
file = request.files['file']
filename = file.filename
name, extension = os.path.splitext(filename)
capitalized_name = name.upper()
file_path = 'logos/global_stocks/' + capitalized_name + extension
file.save(file_path)
image = Image.open(file_path)
if image.height > 32:
new_width = int((32 / image.height) * image.width)
resized_image = image.resize((new_width, 32))
resized_image.save(file_path)
resized_image.close()
image.close()
image = Image.open(file_path)
if image.mode in ('RGBA', 'LA') or (image.mode == 'P' and 'transparency' in image.info):
new_image = Image.new("RGBA", image.size, (0, 0, 0))
new_image.paste(image, (0, 0), image)
new_image.save(file_path)
new_image.close()
image.close()
return index()
@app.route('/upload_crypto', methods=['POST']) @app.route('/upload_crypto', methods=['POST'])
def upload_file_crypto(): def upload_file_crypto():
file = request.files['file'] file = request.files['file']