Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
6850e012
Commit
6850e012
authored
9 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
Add python API example
parent
3d4ca69f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+19
-0
19 additions, 0 deletions
README.md
with
19 additions
and
0 deletions
README.md
+
19
−
0
View file @
6850e012
...
...
@@ -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
-
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment