Пример #1
0
 def post(self): # creates a new page
     args = parser.parse_args()
     page_id = args['page_id']
     if page_id is None or "":
         return 400 # bad request
     retval = lambda x: x._to_json(x.id) if x else 400
     return retval(Extraction.add_extraction(page_id))
Пример #2
0
 def post(self): # creates a new page
     args = parser.parse_args()
     url = args['url']
     if url is None or "":
         return 400 # bad request
     retval = lambda x: x._to_json(x.id) if x else 200
     return retval(Page.add_page(url))
Пример #3
0
 def get(self): # returns all Extractions, or returns a specific Extractions based on page_id
     args = parser.parse_args()
     page_id = args['page_id']
     if page_id is None or "": # requested all Extractions
         jsonify = lambda x: x._to_json(x.id) if x else {}
         return map(jsonify, Extraction.get_all_extractions()) 
     else: # requested Extractions filtered by one page_id
         retval = lambda x: x._to_json(x.id) if x else 400
         return retval(Extraction.get_extraction_by_page_id(page_id))
Пример #4
0
 def get(self): # returns all pages, or returns a specific page based on URL
     args = parser.parse_args()
     url = args['url']
     if url is None or "": # requested all Pages
         jsonify = lambda x: x._to_json(x.id) if x else {}
         return map(jsonify, Page.get_all_pages()) 
     else: # requested Pages filtered by one url
         retval = lambda x: x._to_json(x.id) if x else 400
         return retval(Page.get_page_by_url(url))
Пример #5
0
 def put(self, _id):
     retval = lambda x: x._to_json(x.id) if x else 400
     args = parser.parse_args()
     bp_content = args['bp_content']
     if bp_content is not None:
         extraction = Extraction.get_extraction(_id)
         assert extraction is not None
         return retval(extraction.update(bp_content=bp_content))
     jt_content = args['jt_content']
     if jt_content is not None:
         extraction = Extraction.get_extraction(_id)
         assert extraction is not None
         return retval(extraction.update(jt_content=jt_content))