def get_all_notes(user_id, token): """GET to list notes for user takes in parameters from url for user and the jwt """ user = User.get(User.id == user_id).username if not validate_token(user, token): return HTTPResponse(status=500, body={"message": "Validation error."}) res = [] for note in Notes.select(): if note.user.id == user_id: new_note = model_to_dict(note) res.append({ "id": new_note['id'], "title": new_note['title'], "content": new_note['content'] }) new_token = generate_token(user) body = { "user_id": user_id, "token": new_token.decode('utf-8'), 'items': res } return HTTPResponse(status=200, body=body)