Flask image upload and download

图片 Upload and display

Upload save

def save_to_local(file, file_name):         save_dir = app.config['UPLOAD_DIR']

        file.save(os.path.join(save_dir, file_name))

        return '/image/' + file_name

Download display

@app.route('/image/<image_name>')

def view_image(image_name):

        return send_from_directory(app.config['UPLOAD_DIR'], image_name)