parameters: (self)
docstring: Retrieve Capture based on id
docstring_summary: Retrieve Capture based on id
docstring_tokens: Retrieve Capture based on id
function: def get(self):
          """
          Retrieve Capture based on id
          """
          args = EAGERPARSER.parse_args()
          base_url = app.config['BASE_URL']
  
          app.config.update(USE_S3='')
          # Parse out url and capture type
          capture_record = Capture()
          capture_record.url = args["url"]
          capture_type = args["type"]
  
          if capture_type not in ['html', 'sketch', 'scrape']:
                  return 'Incorrect capture type specified: html, sketch, or scrape', 406
  
          # Write to DB
          try:
              db.session.add(capture_record)
              db.session.commit()
          except IntegrityError, exc:
              return {"error": exc.message}, 500
  
          # Refresh capture_record to obtain an ID for record
          db.session.refresh(capture_record)
  
          try:
              # dict of functions that generate capture names
              capture_names = {'html': grab_domain(capture_record.url) + '_' + str(capture_record.id) + '.html',
                               'sketch': grab_domain(capture_record.url) + '_' + str(capture_record.id) + '.png',
                               'scrape': grab_domain(capture_record.url) + '_' + str(capture_record.id) + '.txt'}
          except:
              return 'This is not a valid URL', 406
  
          # Check that url is valid and responsive
          if not check_url(capture_record):
              return 'Could not connect to URL', 406
  
          # file_to_write is a placeholder in eager calls
          file_to_write = {}
  
          try:
              # Call eager_capture to create scrape, sketch, and html file (blocking)
              files_to_write = tasks.do_capture(200, capture_record, base_url)
  
              if capture_type in capture_names:
                  return send_from_directory(app.config['LOCAL_STORAGE_FOLDER'],
                                             capture_names[capture_type],
                                             as_attachment=True)
              else:
                  return 'Incorrect capture type specified: html, sketch, or scrape', 406
          except Exception as err:
              # Consider updating capture_record status here
              app.logger.error(err)
              return str(err), 406
function_tokens: def get ( self ) : args = EAGERPARSER . parse_args ( ) base_url = app . config [ 'BASE_URL' ] app . config . update ( USE_S3 = '' ) # Parse out url and capture type capture_record = Capture ( ) capture_record . url = args [ "url" ] capture_type = args [ "type" ] if capture_type not in [ 'html' , 'sketch' , 'scrape' ] : return 'Incorrect capture type specified: html, sketch, or scrape' , 406 # Write to DB try : db . session . add ( capture_record ) db . session . commit ( ) except IntegrityError , exc : return { "error" : exc . message } , 500 # Refresh capture_record to obtain an ID for record db . session . refresh ( capture_record ) try : # dict of functions that generate capture names capture_names = { 'html' : grab_domain ( capture_record . url ) + '_' + str ( capture_record . id ) + '.html' , 'sketch' : grab_domain ( capture_record . url ) + '_' + str ( capture_record . id ) + '.png' , 'scrape' : grab_domain ( capture_record . url ) + '_' + str ( capture_record . id ) + '.txt' } except : return 'This is not a valid URL' , 406 # Check that url is valid and responsive if not check_url ( capture_record ) : return 'Could not connect to URL' , 406 # file_to_write is a placeholder in eager calls file_to_write = { } try : # Call eager_capture to create scrape, sketch, and html file (blocking) files_to_write = tasks . do_capture ( 200 , capture_record , base_url ) if capture_type in capture_names : return send_from_directory ( app . config [ 'LOCAL_STORAGE_FOLDER' ] , capture_names [ capture_type ] , as_attachment = True ) else : return 'Incorrect capture type specified: html, sketch, or scrape' , 406 except Exception as err : # Consider updating capture_record status here app . logger . error ( err ) return str ( err ) , 406