main.py 文件源码

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

项目:sentimental-bird 作者: peckjon 项目源码 文件源码
def process_post(self, algorithm, useAt, data={}.copy()):
        """
        handle POST to run the specified algorithm
        :param algorithm: algorithm to run ("user/algorithm/version")
        :param useAt: should '@' be prefixed to 'uid' (in POST body JSON)
        :param data: additional params to send to the algorithm
        :return:
        """
        urlfetch.set_default_fetch_deadline(120)
        uid = extract_uid(self.request.body)
        if not uid:
            return {'error':'Invalid Twitter Username'}
        try:
            data["query"] = '@'+uid if useAt else uid
            cache_key = algorithm+' '+json.dumps(collections.OrderedDict(sorted(data.items())))
            result = memcache.get(cache_key)
            if result is None:
                data["auth"] = TWITTER_AUTH_DICT
                result = call_algorithmia(algorithm, data).result
                memcache.add(cache_key, result, settings.AG_CACHE_SECONDS)
            return result
        except Exception as x:
            return {'error': str(x)}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号