예제 #1
0
def api_split_urls(host):

    if request.headers['Content-Type'] == 'application/json':
        if request.json["urls"] == '<all>':
            urls = utils.get_file_contents(host)
            urls = utils.divide_in_out_urls(host, urls)['in_urls']
            return Response(json.dumps({
                'status': 'OK',
                'urls': utils.parse_urls(urls)
            }),
                            status=200,
                            mimetype='application/json')
        else:
            return Response(json.dumps({
                'status': 'error',
                'reason': 'not implemented'
            }),
                            status=200,
                            mimetype='application/json')
    else:
        return Response(json.dumps({
            'status': 'error',
            'reason': 'Unsupported Media Type'
        }),
                        status=415,
                        mimetype='application/json')
예제 #2
0
 def update(self, people_entry):
     """ 更新用户档案 """
     url, image_url, blog_url = parse_urls(people_entry)
     self.user_name = u(people_entry.uid.text)
     self.screen_name = u(people_entry.title.text)
     self.location = u(people_entry.location.text)
     self.content = u(people_entry.content.text)
     self.url = url
     self.image_url = image_url
     self.blog_url = blog_url
     self.put()
예제 #3
0
def api_split_urls(host):

    if request.headers['Content-Type'] == 'application/json':
        if request.json["urls"] == '<all>':
            urls = utils.get_file_contents(host)
            urls = utils.divide_in_out_urls(host, urls)['in_urls']
            return Response(json.dumps({'status': 'OK', 'urls': utils.parse_urls(urls)}), status=200, mimetype='application/json')
        else:
            return Response(json.dumps({'status': 'error', 'reason': 'not implemented'}), status=200, mimetype='application/json')
    else:
        return Response(json.dumps({'status': 'error', 'reason': 'Unsupported Media Type'}), status=415, mimetype='application/json')
예제 #4
0
 def insert(cls, people_entry):
     """ 新建用户档案 """
     url, image_url, blog_url = parse_urls(people_entry)
     new_profile = DoubanProfile(douban_id=parse_id(people_entry), \
                                 user_name=u(people_entry.uid.text), \
                                 screen_name=u(people_entry.title.text), \
                                 location=u(people_entry.location.text), \
                                 content=u(people_entry.content.text), \
                                 url=url, \
                                 image_url=image_url, \
                                 blog_url=blog_url)
     new_profile.put()
     return new_profile