Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import requests
import datetime
import shutil
from bs4 import BeautifulSoup
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
import base64
from .__init__ import __version__ as ipwbVersion
DEBUG = False
IPFS_API = ipwbUtils.createIPFSClient()
if IPFS_API is None:
print("Error initializing IPFS API client")
sys.exit()
def s2b(s): # Convert str to bytes, cross-py
return bytes(s) if PY2 else bytes(s, 'utf-8')
# TODO: put this method definition below indexFileAt()
def pushToIPFS(hstr, payload):
ipfsRetryCount = 5 # WARC->IPFS attempts before giving up
retryCount = 0
while retryCount < ipfsRetryCount:
try:
# Py 2/3 str/unicode/byte resolution
from flask import flash
from werkzeug.utils import secure_filename
from flask import send_from_directory
from flask import make_response
UPLOAD_FOLDER = tempfile.gettempdir()
ALLOWED_EXTENSIONS = ('.warc', '.warc.gz')
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
app.debug = False
IPFS_API = ipwbUtils.createIPFSClient()
if IPFS_API is None:
print("Error initializing IPFS API client")
sys.exit()
@app.context_processor
def formatters():
return {'pluralize': lambda x, s, p: "{} {}".format(x, s if x == 1 else p)}
@app.after_request
def setServerHeader(response):
response.headers['Server'] = 'InterPlanetary Wayback Replay/' + ipwbVersion
response.autocorrect_location_header = False
return response