Travel Sample - Web App - Can not login/create user


I try to download the travel demo from this repository:

I have try to run with the latest server version: Couchbase Server 6.0 but appears some errors.
I can’t create user/login user. I have download the latest version - Couchbase Server 6.0 and I have in my server the travel bucket demo.¿Perhaps this problem is for this new version?¿ How can I solve it with server version 6.0?

Any help, please.

My output:

Connecting to: couchbase://localhost/travel-sample?username=Administrator
 * Running on (Press CTRL+C to quit) - - [15/Jan/2019 19:12:59] "GET / HTTP/1.1" 302 - - - [15/Jan/2019 19:12:59] "GET /static/index.html HTTP/1.1" 200 - - - [15/Jan/2019 19:13:00] "GET /static/assets/CBTravel.LOGO.png HTTP/1.1" 200 - - - [15/Jan/2019 19:13:00] "GET /static/assets/poweredBy.01.png HTTP/1.1" 200 -
[2019-01-15 19:13:06,733] ERROR in app: Exception on /api/user/signup [POST]
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/", line 33, in reraise
    raise value
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/", line 200, in proxy
    response = view(**request.view_args)
  File "", line 183, in signup
    respjson = jsonify({'data': {'token': token}})
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/", line 263, in jsonify
    (dumps(data, indent=indent, separators=separators), '\n'),
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/", line 123, in dumps
    rv = _json.dumps(obj, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/", line 238, in dumps
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/", line 201, in encode
    chunks = list(chunks)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/", line 405, in _iterencode_dict
    yield from chunks
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/", line 405, in _iterencode_dict
    yield from chunks
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/", line 438, in _iterencode
    o = _default(o)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/", line 80, in default
    return _json.JSONEncoder.default(self, o)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type bytes is not JSON serializable - - [15/Jan/2019 19:13:06] "POST /api/user/signup HTTP/1.1" 500 -

Hey @Berenice

For Couchbase Server 5.0 and above you need to use a different branch of the sample app, which is mentioned at the top of the README of that link: " For Couchbase Server 5.0 see this branch for latest changes to authentication" . Could you give that a try and let us know if it resolves the problem?

Thanks for your reply @graham.pople ,
Yes I have tried to run the code of the branch 5.0 in a Couchbase Server 6.0 (CE) , but it runs with the errors that I mentioned.

Ok thanks for trying that, I’ve pinged one of my Pythonista colleagues to see if they can assist further.

Thanks @graham.pople for your help!

Hi @Berenice

This looks like a Python 3 compatibility issue - on Python 2, str and bytes objects are interchangeable, whereas they are distinct on Python 3. The username has already been UTF8 encoded into a byte sequence before being passed to jsonify.encode - which does not accept Python 3 bytes objects.

I will try to fix this.

In the meantime, are you able to try the sample with Python 2?



Hi @ellis.breen,
I try the sample with Python 2 and it runs :slight_smile: :clap:
I am a beginner…so pls, let me know when it is fixed it.

Thanks for your help,

You’re welcome… I’ve raised a JIRA here: which you can follow.



1 Like