Skip to content

Instantly share code, notes, and snippets.

@DarkSector
Created November 11, 2012 15:45
Show Gist options
  • Select an option

  • Save DarkSector/4055272 to your computer and use it in GitHub Desktop.

Select an option

Save DarkSector/4055272 to your computer and use it in GitHub Desktop.
@app.route('/panel/product/upload/image', methods=['POST'])
def upload_product_image():
image_name = flask.request.args['qqfile']
product_image_path = os.path.join(app_config('PRODUCT_IMAGES'), image_name)
product_thumbnail_path = os.path.join(app_config('PRODUCT_IMAGES_THUMBNAILS'), image_name)
with open(product_image_path, 'w') as fh:
fh.write(flask.request.stream.read())
im = Image.open(product_image_path)
with open(product_thumbnail_path, 'w') as fh:
image_resize(im, (100, 100), False, fh)
return flask.jsonify(success = True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment