diff --git a/README.md b/README.md index f0dfaf0246ff010df196718abbdfb800cbb84369..d8d30dc4c8a3b8e5d3a90c36e2dcad29ae2fb5d6 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ See the wiki: <https://github.com/savoirfairelinux/opendht/wiki> Examples - +### C++ example The `tools` directory includes simple example programs : * `dhtnode`, a command line tool, mostly used for debuging, allowing to perform operations supported by the library (get, put etc.) with text values. * `dhtchat`, a very simple IM client working over the dht. @@ -59,6 +60,24 @@ int main() return 0; } ``` +### Python 3 example +```python +import opendht as dht + +r = dht.DhtRunner() +r.run() + +# Join the network through any running node, +# here using a known bootstrap node. +r.bootstrap("bootstrap.ring.cx", "4222") + +r.put(dht.InfoHash.get("unique_key"), dht.Value(b'some binary data')) + +# blocking call (provide a get_cb and an optional done_cb argument to make the call non-blocking) +results = r.get(dht.InfoHash.get("unique_key")) +for r in results: + print(r) +``` How-to build and install -