How to use the webargs.flaskparser.parser.parse function in webargs

To help you get started, we’ve selected a few webargs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marshmallow-code / webargs / tests / apps / flask_app.py View on Github external
def echo_file():
    args = {"myfile": fields.Field()}
    result = parser.parse(args, locations=("files",))
    fp = result["myfile"]
    content = fp.read().decode("utf8")
    return J({"myfile": content})
github marshmallow-code / webargs / tests / apps / flask_app.py View on Github external
def echo_nested_many_with_data_key():
    data_key_kwarg = {
        "load_from" if (MARSHMALLOW_VERSION_INFO[0] < 3) else "data_key": "X-Field"
    }
    args = {"x_field": fields.Nested({"id": fields.Int()}, many=True, **data_key_kwarg)}
    return J(parser.parse(args))
github fedspendingtransparency / data-act-broker-backend / dataactbroker / decorators.py View on Github external
def wrapped(*args, **kwargs):
        req_args = webargs_parser.parse({
            'submission': webargs_fields.Int(),
            'submission_id': webargs_fields.Int()
        })
        submission_id = req_args.get('submission', req_args.get('submission_id'))
        if submission_id is None:
            raise ResponseException("submission_id is required", StatusCode.CLIENT_ERROR)
        return fn(submission_id, *args, **kwargs)
    return wrapped
github sebastiandev / peach / peach / handlers / flask / resource.py View on Github external
def parse(self, request, supported_args):
        self._req = request
        self._parsed_args = ObjectDict(**req_parser.parse(supported_args))
github gae-init / gae-init / main / api / v1 / auth.py View on Github external
def post(self):
    args = parser.parse({
      'username': wf.Str(missing=None),
      'email': wf.Str(missing=None),
      'password': wf.Str(missing=None),
    })
    handler = args['username'] or args['email']
    password = args['password']
    if not handler or not password:
      return flask.abort(400)

    user_db = model.User.get_by(
      'email' if '@' in handler else 'username', handler.lower()
    )

    if user_db and user_db.password_hash == util.password_hash(user_db, password):
      auth.signin_user_db(user_db)
      return helpers.make_response(user_db, model.User.FIELDS)
github gae-init / gae-init / main / model / user.py View on Github external
def get_dbs(
    cls, admin=None, active=None, verified=None, permissions=None, **kwargs
  ):
    args = parser.parse({
      'admin': wf.Bool(missing=None),
      'active': wf.Bool(missing=None),
      'verified': wf.Bool(missing=None),
      'permissions': wf.DelimitedList(wf.Str(), delimiter=',', missing=[]),
    })
    return super(User, cls).get_dbs(
      admin=admin or args['admin'],
      active=active or args['active'],
      verified=verified or args['verified'],
      permissions=permissions or args['permissions'],
      **kwargs
    )
github teracyhq-incubator / flask-boilerplate / app / api_1_0 / token.py View on Github external
def create(self):
        """Login and return JWT token
        """
        args = parser.parse(utils.merge_dict(_user_args, self.common_args))
        user = jwt_authenticate(args.get('email'), args.get('password'))
        if user:
            # TODO(hoatle): support to make response from dict
            return self._token_result(user, args.get('expires_in'))

        raise BadRequestException(
            'Invalid Credentials',
            description='email or password is not correct'
        )

webargs

Declarative parsing and validation of HTTP request objects, with built-in support for popular web frameworks, including Flask, Django, Bottle, Tornado, Pyramid, Falcon, and aiohttp.

MIT
Latest version published 4 months ago

Package Health Score

88 / 100
Full package analysis

Similar packages