Пример #1
0
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())
Пример #2
0
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())
Пример #3
0
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"
Пример #4
0
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"
Пример #5
0
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)
Пример #6
0
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)