I need to respond directly to True or False. How can I do this? Json, text, raw.... can't
` File "/usr/local/lib/python3.5/dist-packages/sanic/server.py", line 337, in write_response
response.output(
AttributeError: 'bool' object has no attribute 'output'
if param == signature:
return True
else:
return False
`
@EdwardBetts @cbess @kolanos @dkruchinin @joar
return json(True)
Well, responding with a boolean has a lot of meanings.
response.text and return 0 or 1 or true or false??response.raw?At the end of the day, boolean is a bit... and a (decimal or string) representation is what you see. If you really want to send a 1 bit, then I think you're better off with another internet protocol??
import ujson
from sanic import response
@bp.route('/data', methods=['GET'])
async def some_call(request):
value = True
return response.text(f'{value}')
# or
return response.text(ujson.dumps(value))
# or using json
return response.json(value)
# using raw (HTTP is text based) so...
# but this wont have encoding...
return response.raw(f'{value}')
Most helpful comment
Well, responding with a boolean has a lot of meanings.
response.textand return0or1ortrueorfalse??response.raw?At the end of the day, boolean is a bit... and a (decimal or string) representation is what you see. If you really want to send a
1bit, then I think you're better off with another internet protocol??https://sanic.readthedocs.io/en/latest/sanic/response.html