Skip to main content

Pyper

The Piper networking protocol in Python.

How to install?

The version on pypi is the stable version, and the version on github is the development version.

To get it from pypi use:

pip3 install pyper-piper

To install from github use:

pip3 install git+https://github.com/Bigjango13/Pyper

If you are making you're own changes to pyper it can be installed with

pip3 install path/to/pyper

How to use?

An example server and an example client can be found under the examples directory.

Common

Piper specification version

The piper specification version that pyper is currently based on can be accesesed throught the piperSpecVersion variables.

Content types

These content types can be used instead of the ids for content types, here they are:

utf8 (00)
gemtext (01)
ascii (02)
file (10)
redirect (20)
notFound (22)
internalError (23)
specVersion (24)
There are also some content types from libpiper for compatibility.
clientOutOfMemory (F0)
clientConnectionError (F1)
clientInternalError (F2)
There is also one I added to handle invaid data sent from the server.
clientInvalidData (F3)

There is also a dictonary that can be used to translate the content types into more human friendly variants, it is called contentType.

Debugging

The pyperDebug variable will toggle printing the packets, it defaults to whatever PYPER_DEBUG is set to (None in most cases) but can be changed in python.

Client

getUrlRedirect(originalUrl, originalUrlPort, url)

Takes the current url, the current port, and the url that the current url is telling you to redirect to.

Gets the url to redirect to and returns the arguments for pyper.client.connect.

getHostname(ip, port, path, args)

Return the formated url.

connectFromUrl(url)

Returns the arguments for pyper.client.connect (excluding redirectsAllowed) from a piper url.

connect(ip, port, path, options, redirectsAllowed)

Connects to a piper server based on the ip, port, path, and options.

If redirectsAllowed is not equal to zero it will also automatically follow redirects and remove one from redirectsAllowed, if it is set below zero it will always redirect.

Server

PyperServer

__init__(port)

Creates a pyper server and binds it to the ip and port.

start()

Starts the server.

parseRequest(path)

Meant to be used as a decorator, it maps a function to a path.

For example:

import pyper

pyperServer = pyper.server.PyperServer()

@pyperServer.parseRequest("/")
def index(request):
    return pyper.common.ascii, "This is the index"

pyperServer.start()

if the option is "*" pyper will use it as a fallback for when a page isn't found (good for making a custom 0x22 page).

request is dictionary that includes client_addr (the address of the client), options (a dictionary of the url options), and path (the url path).

Metadata

Release files for pyper-piper 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyper-piper 0.1.6
File Size Uploaded Provenance
pyper-piper-0.1.6.tar.gz 6.8 kB Without provenance Details

Release files / pyper-piper-0.1.6.tar.gz

Download URL pyper-piper-0.1.6.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8454dfc9b8a7fa8c793082f24e303b1da04907b2b8798f9c2f164aa456e13237
BLAKE2b-256 checksum
How to use checksums
90a6368bb5fb1f97cd959e01509343b9ece7be744c82e7f1b9226064f8cb0eaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.2

Security for pyper-piper 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page