def render(id): picture = Picture.get(Picture.id == id) if request.method == 'GET': pixels = Pixels() pixels.get_pixels_from_img(picture) if not g.authorized or picture.user.id != g.user.id: return render_template('showpicture.html', picture=picture, pixels=json.dumps(pixels.to_hash()), group_size=current_app.config['GROUP_SIZE'], export_pic_size=current_app.config['EXPORT_GROUP_SIZE'], palette=json.dumps(Palette.load_from_db(picture)), ) else: return render_template('render.html', picture=picture, pixels=json.dumps(pixels.to_hash()), access_token=g.user.access_token, group_size=current_app.config['GROUP_SIZE'], export_pic_size=current_app.config['EXPORT_GROUP_SIZE'], palette=json.dumps(Palette.load_from_db(picture)), ) else: Palette.remove_from_db(picture) return jsonify(result='ok')
def render(id): picture = Picture.get(Picture.id == id) if request.method == 'GET': pixels = Pixels() pixels.get_pixels_from_img(picture) if not g.authorized or picture.user.id != g.user.id: return render_template( 'showpicture.html', picture=picture, pixels=json.dumps(pixels.to_hash()), group_size=current_app.config['GROUP_SIZE'], export_pic_size=current_app.config['EXPORT_GROUP_SIZE'], palette=json.dumps(Palette.load_from_db(picture)), ) else: return render_template( 'render.html', picture=picture, pixels=json.dumps(pixels.to_hash()), access_token=g.user.access_token, group_size=current_app.config['GROUP_SIZE'], export_pic_size=current_app.config['EXPORT_GROUP_SIZE'], palette=json.dumps(Palette.load_from_db(picture)), ) else: Palette.remove_from_db(picture) return jsonify(result='ok')
def palette(id): try: picture = Picture.get(Picture.id==id) except Picture.DoesNotExist: return 'Not found', 404 if not g.authorized or picture.user.id != g.user.id: return 'error', 500 if Palette.save_to_db(picture, request.form['palette']): return jsonify(result='ok') else: return jsonify(error='wrong data'), 500
def palette(id): try: picture = Picture.get(Picture.id == id) except Picture.DoesNotExist: return 'Not found', 404 if not g.authorized or picture.user.id != g.user.id: return 'error', 500 if Palette.save_to_db(picture, request.form['palette']): return jsonify(result='ok') else: return jsonify(error='wrong data'), 500