Если вы используете примеры в readme, просто посмотрите на свойство length объекта rows (т. е. rows.length).
def signup(self, username, password, confirm, client):
return self.app.post(
'/signup',
data=json.dumps(dict(username=username, password=password, confirm=confirm, client=client)), content_type='application/json')
Mimetype должен быть установлен на mimetype='application/json'
в качестве дополнительного параметра внутри пост-вызова.
def signup(self, username, password, confirm, client):
return self.app.post(
'/signup',
data=json.dumps(dict(username=username, password=password, confirm=confirm, client=client)),
follow_redirects=True, mimetype='application/json'
)
Документы описывают атрибуты, доступные по запросу. В большинстве распространенных случаев request.data будет пустым, поскольку он используется в качестве запасного варианта:
request.data Contains the incoming request data as string in case it came with a mimetype Flask does not handle.
request.args: the key/value pairs in the URL query string
request.form: the key/value pairs in the body, from a HTML post form, or JavaScript request that isn't JSON encoded
request.files: the files in the body, which Flask keeps separate from form. HTML forms must use enctype=multipart/form-data or files will not be uploaded.
request.values: combined args and form, preferring args if keys overlap
Все это экземпляры MultiDict. Вы можете получить доступ к значениям, используя:
request.form['name']: use indexing if you know the key exists
request.form.get('name'): use get if the key might not exist
request.form.getlist('name'): use getlist if the key is sent multiple times and you want a list of values. get only returns the first value.