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


Python datastructures.CombinedMultiDict方法代码示例

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


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

示例1: values

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import CombinedMultiDict [as 别名]
def values(self) -> CombinedMultiDict:
        form = await self.form
        return CombinedMultiDict([self.args, form]) 
开发者ID:pgjones,项目名称:quart,代码行数:5,代码来源:request.py

示例2: post

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import CombinedMultiDict [as 别名]
def post():
  form = PhotoForm(CombinedMultiDict((request.files, request.form)))
  if request.method == 'POST' and form.validate():
    with tempfile.NamedTemporaryFile() as temp:
      form.input_photo.data.save(temp)
      temp.flush()
      result = detect_objects(temp.name)

    photo_form = PhotoForm(request.form)
    return render_template('upload.html',
                           photo_form=photo_form, result=result)
  else:
    return redirect(url_for('upload')) 
开发者ID:GoogleCloudPlatform,项目名称:tensorflow-object-detection-example,代码行数:15,代码来源:app.py

示例3: wrap_formdata

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import CombinedMultiDict [as 别名]
def wrap_formdata(self, form, formdata):
            if formdata is _Auto:
                if _is_submitted():
                    if request.files:
                        return CombinedMultiDict((
                            request.files, request.form
                        ))
                    elif request.form:
                        return request.form
                    elif request.get_json():
                        return ImmutableMultiDict(request.get_json())

                return None

            return formdata 
开发者ID:liantian-cn,项目名称:RSSNewsGAE,代码行数:17,代码来源:form.py

示例4: post

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import CombinedMultiDict [as 别名]
def post():
    form = PhotoForm(CombinedMultiDict((request.files, request.form)))
    if request.method == 'POST' and form.validate():
        filename = '%s.%s' % (str(uuid.uuid4()),
                              secure_filename(form.input_photo.data.filename))
        content_type = content_types[filename.split('.')[-1]]
        write_retry_params = gcs.RetryParams(backoff_factor=1.1)
        gcs_file = gcs.open('/%s/%s' % (bucket_name, filename), 'w',
                            retry_params=write_retry_params,
                            content_type=content_type,
                            options={'x-goog-acl': 'authenticated-read'})
        for _ in form.input_photo.data.stream:
            gcs_file.write(_)
        gcs_file.close()

        labels = get_labels(filename)
        tags = [translate_text(label.description) for label in labels]
        entity = Photo(id=filename, tags=tags,
                       parent=ndb.Key('User', 'default'))
        entity.put()

        for tag in tags:
            entity = ndb.Key('User', 'default', 'Tags', tag).get()
            if entity:
                entity.count += 1
            else:
                entity = Tags(count=1, id=tag,
                              parent=ndb.Key('User', 'default'))
            entity.put()
        return render_template('post.html', storage_path=storage_path,
                               filename=filename, tags=tags)
    else:
        return redirect(url_for('photos')) 
开发者ID:GoogleCloudPlatform,项目名称:appengine-photoalbum-example,代码行数:35,代码来源:main.py

示例5: upload

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import CombinedMultiDict [as 别名]
def upload():
    upload_form = forms.UploadForm(CombinedMultiDict((flask.request.files, flask.request.form)))
    upload_form.category.choices = _create_upload_category_choices()

    show_ratelimit = False
    next_upload_time = None
    ratelimit_count = 0

    # Anonymous uploaders and non-trusted uploaders

    no_or_new_account = (not flask.g.user
                         or (flask.g.user.age < app.config['RATELIMIT_ACCOUNT_AGE']
                             and not flask.g.user.is_trusted))

    if app.config['RATELIMIT_UPLOADS'] and no_or_new_account:
        now, ratelimit_count, next_upload_time = backend.check_uploader_ratelimit(flask.g.user)
        show_ratelimit = ratelimit_count >= app.config['MAX_UPLOAD_BURST']
        next_upload_time = next_upload_time if next_upload_time > now else None

    if flask.request.method == 'POST' and upload_form.validate():
        try:
            torrent = backend.handle_torrent_upload(upload_form, flask.g.user)

            return flask.redirect(flask.url_for('torrents.view', torrent_id=torrent.id))
        except backend.TorrentExtraValidationException:
            pass

    # If we get here with a POST, it means the form data was invalid: return a non-okay status
    status_code = 400 if flask.request.method == 'POST' else 200
    return flask.render_template('upload.html',
                                 upload_form=upload_form,
                                 show_ratelimit=show_ratelimit,
                                 ratelimit_count=ratelimit_count,
                                 next_upload_time=next_upload_time), status_code 
开发者ID:nyaadevs,项目名称:nyaa,代码行数:36,代码来源:torrents.py

示例6: test_iterables

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import CombinedMultiDict [as 别名]
def test_iterables(self):
        a = datastructures.MultiDict((("key_a", "value_a"),))
        b = datastructures.MultiDict((("key_b", "value_b"),))
        ab = datastructures.CombinedMultiDict((a,b))

        self.assert_equal(sorted(ab.lists()), [('key_a', ['value_a']), ('key_b', ['value_b'])])
        self.assert_equal(sorted(ab.listvalues()), [['value_a'], ['value_b']])
        self.assert_equal(sorted(ab.keys()), ["key_a", "key_b"])

        self.assert_equal(sorted(iterlists(ab)), [('key_a', ['value_a']), ('key_b', ['value_b'])])
        self.assert_equal(sorted(iterlistvalues(ab)), [['value_a'], ['value_b']])
        self.assert_equal(sorted(iterkeys(ab)), ["key_a", "key_b"]) 
开发者ID:GeekTrainer,项目名称:Flask,代码行数:14,代码来源:datastructures.py


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