views.py 文件源码

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

项目:CactusAPI 作者: CactusDev 项目源码 文件源码
def chan_friends(channel):
    """
    If you GET this endpoint, go to /api/v1/channel/<channel>/friend
    with <channel> replaced for the channel of the friends you want to get

    <channel> can either be an int that matches the channel, or a string
    that matches the owner's username
    """

    # model = request.path.split("/")[-1]
    model = "Friend"

    if channel.isdigit():
        fields = {"channelId": int(channel)}
    else:
        fields = {"owner": channel.lower()}

    packet, code = generate_response(
        model,
        request.path,
        request.method,
        request.values,
        data=results,
        fields=fields
    )

    return make_response(jsonify(packet), code)

    # There was an error!
    # if not str(code).startswith("2"):
    #    return make_response(jsonify(packet), code)
    # NOTE: Not needed currently, but this is how you would check


# TODO: Fix this endpoint to remove timing elements (friends are forever)
# TODO: Use Object.update(**changes) instead of Object(**updated_object).save()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号