Metadata-Version: 2.1
Name: iptt
Version: 1.0.2
Summary: InterPlanetary Tunnel Toolkit
Home-page: https://gitlab.com/galacteek/iptt/iptt
Author: cipres
Author-email: galacteek@protonmail.com
License: DEV-NULL
Keywords: ipfs,http
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Dist: async-timeout (>=3.0.0)
Requires-Dist: attrs (>=22.1.0)
Requires-Dist: aioipfs (>=0.5.9)
Requires-Dist: aiologger (>=0.7.0)
Requires-Dist: ptpython (>=3.0.20)
Requires-Dist: uvloop (>=0.17.0)

InterPlanetary Tunnel Toolkit
=============================

Provides tools to communicate with existing network protocols over
IPFS tunnels (libp2p streams).

- *iphttp*: Command-line iphttp client
- *iphttpd*: iphttp server (can serve *aiohttp* apps or just forward to an
  existing HTTP service)

.. code-block:: bash

    pip install -U iptt

iphttp
======

*iphttp* is the command-line client. To make a simple GET request,
pass the PeerId with the HTTP path:

.. code-block:: bash

    iphttp QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc/doc.txt

Use *--maddr* to pass the RPC API multiaddr_ of your kubo_ node (the
default multiaddr is */ip4/127.0.0.1/tcp/5001*) :

.. code-block:: bash

    iphttp --maddr /dns4/localhost/tcp/5010 \
        QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc/summary.html

Interactive mode: just pass a PeerId and all requests in the CLI
session will be based on that peer.

.. code-block:: bash

    iphttp -i QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc

The following commands are supported in interactive mode:

- get(path: str, q={}, h={}): HTTP GET request on path *path* with query *q*
  and HTTP headers *h* (dict)

- post(path: str, q={}, data={}, h={}): HTTP POST request on path with post data *data*, HTTP query *q* (dict) and HTTP headers *h* (dict)

.. code-block:: python

    get('/')
    get('/', q={'arg1': 4})
    get('/', h={'X-Important-Header': 'some-value'})

    post('/form', q={'arg1': 2}, data={'message': 'Form field data'})
    post('/form', data={'message': 'Form field data'})

iphttpd
=======

*iphttpd* allows you to register an IPFS P2P service for an
already running HTTP server, and can also serve an HTTP application
from a Python module (only *aiohttp* apps are supported right now).

Example 1
---------

Serve **http://localhost:7000** for the P2P protocol **/x/ipfs-http/80/1.0**

.. code-block:: bash

    iphttpd -l localhost:7080

Example 2
---------

Serve **http://localhost:8080** for the P2P protocol **/x/ipfs-http/8000/1.0**

.. code-block:: bash

    iphttpd --public-port 8000 -l localhost:8080

Example 3
---------

Serve an aiohttp application from Python module
**iphttpd_apps.helloworld**:

.. code-block:: bash

    iphttpd --serve-aiohttp iphttpd_apps.helloworld

Your module should implement the coroutine **create_app(args)** and return
an *aiohttp.web.Application* instance that will be used to run the service
(see the helloworld_ service).

License
=======

**God bless HTTP, and God bless IPFS** license.


.. _helloworld: https://gitlab.com/galacteek/iptt/iptt/-/blob/master/iphttpd_apps/helloworld.py
.. _kubo: https://github.com/ipfs/kubo
.. _multiaddr: https://multiformats.io/multiaddr
