def user_posts(): posts = Post.find_by_user_id(session['USERNAME']) username = User.find_by_id(session['USERNAME']) images = {} for post in posts: directory = os.listdir(post.file_path) file_path = post.file_path images.update({file_path: directory[0]}) return render_template('library.html', posts=posts, images=images, username=username)