Check resp.status_code instead of nonexistent resp.code.