Skip to content

Instantly share code, notes, and snippets.

@gpamfilis
Created August 20, 2018 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gpamfilis/f8af817686cba9016cfb5d0c766a1c52 to your computer and use it in GitHub Desktop.
Save gpamfilis/f8af817686cba9016cfb5d0c766a1c52 to your computer and use it in GitHub Desktop.
gallery snipet
def gallery(location='static/img/gallery'):
gallery_categories = os.path.join(os.path.sep, basedir, 'app', *location.split('/'))
categories = os.listdir(gallery_categories)
images_full_path = []
for category in categories:
images = os.path.join(os.path.sep, basedir, 'app', *location.split('/'), category)
for image in os.listdir(images):
image_path = os.path.join(*location.split('/'), category, image)
images_full_path.append([category, image_path])
return categories, images_full_path
@main.route('/projects')
def projects():
categories, images_full_path = gallery()
return render_template('boot_studio/projects.html', categories=categories, images_full_path=images_full_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment