views.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Startup-Fairy 作者: cs373gc-fall-2016 项目源码 文件源码
def api_companies(entity=None):
    """
    api route for companies
    :param entity: is the id of a company or None
    :return: json with results or 404
    """
    try:
        company_id = request.args.get('id')
        if entity is None and company_id is None:
            return get_all_from_category(Company)
        else:
            if entity is not None:
                data = db.session.query(Company).filter_by(
                    company_id=entity).one()
            else:
                data = db.session.query(Company).filter_by(
                    company_id=company_id).one()
            return json.dumps(data.dictionary())
    except SQLAlchemyError:
        print("Get companies failed")
        abort(404)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号