You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[2019-04-24 15:10:09,368] ERROR in app: Exception on /assets [GET]
Traceback (most recent call last):
File "/Users/gbehm/miniconda3/envs/plaid37/lib/python3.7/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/Users/gbehm/miniconda3/envs/plaid37/lib/python3.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/gbehm/miniconda3/envs/plaid37/lib/python3.7/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/gbehm/miniconda3/envs/plaid37/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/Users/gbehm/miniconda3/envs/plaid37/lib/python3.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/gbehm/miniconda3/envs/plaid37/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "server.py", line 158, in get_assets
'pdf': base64.b64encode(asset_report_pdf),
File "/Users/gbehm/miniconda3/envs/plaid37/lib/python3.7/site-packages/flask/json/__init__.py", line 321, in jsonify
dumps(data, indent=indent, separators=separators) + '\n',
File "/Users/gbehm/miniconda3/envs/plaid37/lib/python3.7/site-packages/flask/json/__init__.py", line 179, in dumps
rv = _json.dumps(obj, **kwargs)
File "/Users/gbehm/miniconda3/envs/plaid37/lib/python3.7/json/__init__.py", line 238, in dumps
**kw).encode(obj)
File "/Users/gbehm/miniconda3/envs/plaid37/lib/python3.7/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/Users/gbehm/miniconda3/envs/plaid37/lib/python3.7/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/Users/gbehm/miniconda3/envs/plaid37/lib/python3.7/site-packages/flask/json/__init__.py", line 81, in default
return _json.JSONEncoder.default(self, o)
File "/Users/gbehm/miniconda3/envs/plaid37/lib/python3.7/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type bytes is not JSON serializable
In Python 3, base64.b64encode(asset_report_pdf) accepts a bytes-like object and returns encoded bytes. The interface changed from Python 2.7, where base64.b64encode(asset_report_pdf) accepts a str and returns an encoded str.
For Python 3, the output of base64.b64encode(asset_report_pdf) should be converted to str before attempting to jsonify.
The text was updated successfully, but these errors were encountered:
The server.py Asset Report code attempts to
jsonify
the base-64-encoded PDF report:For Python 3, this throws a
TypeError
exception:In Python 3,
base64.b64encode(asset_report_pdf)
accepts a bytes-like object and returns encoded bytes. The interface changed from Python 2.7, wherebase64.b64encode(asset_report_pdf)
accepts astr
and returns an encodedstr
.For Python 3, the output of
base64.b64encode(asset_report_pdf)
should be converted tostr
before attempting tojsonify
.The text was updated successfully, but these errors were encountered: