api.py 文件源码

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

项目:love 作者: Yelp 项目源码 文件源码
def api_send_loves():
    sender = request.form.get('sender')
    recipients = sanitize_recipients(request.form.get('recipient'))
    message = request.form.get('message')

    try:
        recipients = send_loves(recipients, message, sender_username=sender)
        recipients_display_str = ', '.join(recipients)
        link_url = create_love_link(recipients_display_str, message).url
        return make_response(
            u'Love sent to {}! Share: {}'.format(recipients_display_str, link_url),
            LOVE_CREATED_STATUS_CODE,
            {}
        )
    except TaintedLove as exc:
        return make_response(
            exc.user_message,
            LOVE_FAILED_STATUS_CODE if exc.is_error else LOVE_CREATED_STATUS_CODE,
            {}
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号