当前位置: 首页>>代码示例>>Python>>正文


Python Article.picture1方法代码示例

本文整理汇总了Python中models.Article.picture1方法的典型用法代码示例。如果您正苦于以下问题:Python Article.picture1方法的具体用法?Python Article.picture1怎么用?Python Article.picture1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Article的用法示例。


在下文中一共展示了Article.picture1方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upload_product

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import picture1 [as 别名]
def upload_product():
  form = ProductUploadForm(request.form)
  if request.method == 'POST':
    picture_count = 0
    file1 = request.files["picture1"] # request.files is a dictionary with the name matching
                                    # the input name

    # only one picture is required the others can be skipped
    file2 = request.files["picture2"]
    file3 = request.files["picture3"]
    keywords = request.form["keywords"]
    product_name = request.form["product_name"]
    # email is temporary now. Later it will be replaced with open id or other method
    #condition = request.form["condition"]
    #return "%s" % (request.form.keys())
    if file1 and allowed_file(file1.filename):
      filename1 = secure_filename(file1.filename)
      # switching to Google Datastore model - previous way used to store files in server
      article = Article(product_name=product_name, keywords = keywords, condition="needs fixing")
      image1 = file1.getvalue()
      #imagerz1 = images.resize(image1, 1024, 768) # only on production
      imagerz1 = image1
      article.picture1 = db.Blob(imagerz1)
      picture_count += 1
      if file2 and allowed_file(file2.filename):
        image2 = file2.getvalue()
        #imagerz2 = images.resize(image2, 1024, 768) # only on production
        imagerz2 = image2
        article.picture2 = db.Blob(imagerz2)
        picture_count += 1
      if file3 and allowed_file(file3.filename):
        image3 = file3.getvalue()
        #imagerz3 = images.resize(image3, 1024, 768) # only on production
        imagerz3 = image3
        article.picture3 = db.Blob(imagerz3)
        picture_count += 1
      article.picture_count = picture_count
      article.put()
      #return "this are the values %s" % str(file_.keys())
      return redirect(url_for('buy'))
      #return render_template('show.html', filename=product_name)
  return render_template('upload_flask.html', form = form)
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:44,代码来源:views.py


注:本文中的models.Article.picture1方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。