コード例 #1
0
 def post(self):
     url = request.json.get('url', '')
     annotation = request.json.get('annotation', '')        
     wayback = save(url)
     wayback_url = '%s%s' % (WAYBACK_SERVER, wayback['id'])
     if not annotation:
         raise Exception("Page archived as %s but no annotation detected" \
                         % wayback_url)
     annotation['hasTarget']= {
         'hasSource': {
             '@id': wayback_url,
             'originalUrl': '%s://%s%s' % (
                 wayback['protocol'],
                 wayback['domain'],
                 wayback['path']
             )
         }
     }
     annotation['annotatedAt'] = datetime.utcnow().ctime()
     p = Pragma(domain=wayback['domain'],
                protocol=wayback['protocol'],
                path=wayback['path'],
                wayback_id=wayback['id'],
                annotation=annotation)
     p.create()
     return p.dict()
コード例 #2
0
 def get(self, pid):
     return Pragma.get(pid).dict()