我需要直接回应 True 或 False。我怎样才能做到这一点?Json, text, raw....不能编码
if param == signature:
return True
else:
return False
错误
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'
附加:
from sanic.response import json, text
@service_bp.route('/custom', methods=['GET'])
async def cutsom(request):
signature = request.args['signature'][0]
timestamp = request.args['timestamp'][0]
nonce = request.args['nonce'][0]
token = mpSetting['custom_token']
param = [token, timestamp, nonce]
param.sort()
param = "".join(param).encode('utf-8')
sha1 = hashlib.sha1()
sha1.update(param)
param = sha1.hexdigest()
print(param, signature, param == signature)
if param == signature:
return json(True)
else:
return json(False)
我只想简单地返回 True 或 False。