def pic(pk): db = util.get_db() db.execute('select * from instaclone_images where id=%s', [pk]) image = db.fetchone() # create filtered image if requested if request.method == 'POST': filter_name = request.form.get('filter') if filter_name in registry: im = util.Image(image) # Get current file image_path = config.DIR + im.absolute_url() # Get new unique filename new_filename = util.new_filename(image_path) # copy old to new by way of selected filter convert_image(image_path, new_filename, filter_name) # and insert into the db pk = util.insert_image(os.path.basename(new_filename), "%s (%s)" % (im.name, filter_name), parent=im.parent_id or im.id, mv=False) return redirect(url_for('pic', pk=pk)) sql = 'select * from instaclone_images where parent_id=%s' db.execute(sql, [pk]) related = db.fetchall() return render_template('image.html', image=image, related=related, filters=registry.keys())
def pic(pk): db = util.get_db() db.execute('select * from instaclone_images where id=%s', [pk]) image = db.fetchone() # create filtered image if requested if request.method == 'POST': filter_name = request.form.get('filter') if filter_name in registry: im = util.Image(image) # Get current file image_path = config.DIR + im.absolute_url() # Get new unique filename new_filename = util.new_filename(image_path) # copy old to new by way of selected filter convert_image(image_path, new_filename, filter_name) # and insert into the db pk = util.insert_image(os.path.basename(new_filename), "%s (%s)" % (im.name, filter_name), parent=im.parent_id or im.id, mv=False ) return redirect(url_for('pic', pk=pk)) sql = 'select * from instaclone_images where parent_id=%s' db.execute(sql, [pk]) related = db.fetchall() return render_template('image.html', image=image, related=related, filters=registry.keys())
def like(pk): db = util.get_db() db.execute('select * from instaclone_images where id=%s', [pk]) image = db.fetchone() if not image: abort(404) curs = db.execute( """insert into instaclone_likes(image) values(%s)""", [pk]) return "1"
def like(pk): db = util.get_db() db.execute('select * from instaclone_images where id=%s', [pk]) image = db.fetchone() if not image: abort(404) curs = db.execute("""insert into instaclone_likes(image) values(%s)""", [pk]) return "1"
def front_page(): db = util.get_db() db.execute("""select * from instaclone_images order by id desc limit 5""") rows = db.fetchall() return render_template('front_page.html', rows=rows, front_page=True)