Library for spartan protocol
Project description
spartan-py
Basic spartan protocol implementation as a python library.
import spartan
res = spartan.get("spartan://mozz.us/echo", "hi")
while True:
buf = res.read()
if not buf:
break
sys.stdout.buffer.write(buf)
res.close()
Try it in the REPL:
>>> import spartan
>>> req = spartan.Request("spartan.mozz.us")
>>> req
>>> <Request spartan.mozz.us:300 / 0>
>>> res = req.send()
>>> res
>>> 2 text/gemini
>>> res.read()
>>> [...]
>>> res.close()
install
pip3 install spartan-py
API
Request(host: str, port: int = 300, path: str = "/", data: str = "")
.send() -> Response
- send the request__repr__()
__str__()
Response(socket)
read()
close()
- close the socket.status
- status code.meta
- meta string for the status__repr__()
__str__()
Status
- statusessuccess = 2
redirect = 3
client_error = 4
server_error = 5
get(url: str, data: str = "") -> Response
- if the query string part in the URL exists, data will be ignored.
TODO
- invalid url handling
- util functions like parsing meta and getting status type
- basic CLI usage
- async methods
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spartan-py-0.2.4.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for spartan_py-0.2.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5824c4d71f398dd49ad0b1c4bdc2e64fb3598a0d609f967a9728ca13621a571b |
|
MD5 | 70f267145e7b97d83238f24c7272f29f |
|
BLAKE2b-256 | 2251163cb5ff0caab7e6ca1ac0c951581e4c42461eef688ae85cd0d46a74b7d8 |