upload global stocks added
This commit is contained in:
parent
2005623025
commit
5673bebad2
30
server.py
30
server.py
@ -2347,6 +2347,36 @@ def upload_file_stocks():
|
||||
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'])
|
||||
def upload_file_crypto():
|
||||
file = request.files['file']
|
||||
|
Loading…
Reference in New Issue
Block a user