Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def showMementosForURIRs(urir):
urir = getCompleteURI(urir)
if ipwbUtils.isLocalHosty(urir):
urir = urir.split('/', 4)[4]
indexPath = ipwbUtils.getIPWBReplayIndexPath()
print('Getting CDXJ Lines with the URI-R {0} from {1}'
.format(urir, indexPath))
cdxjLinesWithURIR = getCDXJLinesWithURIR(urir, indexPath)
if len(cdxjLinesWithURIR) == 1:
fields = cdxjLinesWithURIR[0].split(' ', 2)
redirectURI = '/memento/{1}/{0}'.format(unsurt(fields[0]), fields[1])
return redirect(redirectURI, code=302)
msg = ''
if cdxjLinesWithURIR:
def resolveMemento(urir, datetime):
""" Request a URI-R at a supplied datetime from the CDXJ """
urir = getCompleteURI(urir)
if ipwbUtils.isLocalHosty(urir):
urir = urir.split('/', 4)[4]
s = surt.surt(urir, path_strip_trailing_slash_unless_empty=False)
indexPath = ipwbUtils.getIPWBReplayIndexPath()
print('Getting CDXJ Lines with the URI-R {0} from {1}'
.format(urir, indexPath))
cdxjLinesWithURIR = getCDXJLinesWithURIR(urir, indexPath)
closestLine = getCDXJLineClosestTo(datetime, cdxjLinesWithURIR)
if closestLine is None:
msg = '<h1>ERROR 404</h1>'
msg += 'No capture found for {0} at {1}.'.format(urir, datetime)
return Response(msg, status=404)