def api_people(entity=None):
"""
api route for people
:param entity: is the id of a person or None
:return: json with results or 404
"""
try:
person_id = request.args.get('id')
if entity is None and person_id is None:
return get_all_from_category(Person)
else:
if entity is not None:
data = db.session.query(Person).filter_by(
person_id=entity).one()
else:
data = db.session.query(Person).filter_by(
person_id=person_id).one()
return json.dumps(data.dictionary())
except SQLAlchemyError:
print("Get people failed")
abort(404)
评论列表
文章目录