How to use the ipwb.util.createIPFSClient function in ipwb

To help you get started, we’ve selected a few ipwb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oduwsdl / ipwb / ipwb / indexer.py View on Github external
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
github oduwsdl / ipwb / ipwb / replay.py View on Github external
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