Beispiel #1
0
 def get(self):
     id = self.request.get('id')
     url = self.request.get('url')
     
     if id:
         article = ndb.Key('Article', id).get()
         article.fetch_if_needed(ignore_previous_failure=True)
     else:
         article = api.ensure_article_at_url(url)
     
     send_json(self, article.json(include_article_json=True))
Beispiel #2
0
 def post(self):
     url = self.request.get('url')
     force_mercury = (not not self.request.get('force_mercury'))
     # print 'force mercury:', force_mercury
     article = api.ensure_article_at_url(url, force_fetch=True, force_mercury=force_mercury)
     type = self.request.get('type')
     if type == 'html':
         self.response.write(article.content.get().html)
     elif type == 'article_json':
         self.response.headers.add_header('Content-Type', 'application/json')
         self.response.write(json.dumps({
             "article": article.content.get().article_json
         }))
     else:
         self.response.headers.add_header('Content-Type', 'application/json')
         self.response.write(json.dumps({
             "article": article.json(include_article_json=True)
         }))