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))
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))
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))
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))
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))