SourceCodeofMongoRedis
SourceCodeofMongoRedis copied to clipboard
[chapter_6]修复post_message的if分支逻辑
问题再现
发送消息(由post_message视图函数处理)时,出现
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
原因
post_message视图函数中的expire_time返回-1或者-2,bool(-1) or bool(-2)为True。所以if not expire_time为False。所以没有处理的分支,导致此视图函数return None。
解决办法
if not expire_time -> if expire_time < 1