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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
ae7e2989
Unverified
Commit
ae7e2989
authored
8 years ago
by
Simon Désaulniers
Browse files
Options
Downloads
Patches
Plain Diff
http_server: put values, specific user_type,vid
parent
7197c1fb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/tools/http_server.py
+10
-1
10 additions, 1 deletion
python/tools/http_server.py
with
10 additions
and
1 deletion
python/tools/http_server.py
+
10
−
1
View file @
ae7e2989
...
...
@@ -42,13 +42,22 @@ class DhtServer(resource.Resource):
def
render_POST
(
self
,
req
):
uri
=
req
.
uri
[
1
:]
data
=
req
.
args
[
b
'
data
'
][
0
]
if
b
'
data
'
in
req
.
args
else
None
user_type
=
req
.
args
[
b
'
user_type
'
][
0
].
decode
()
if
b
'
user_type
'
in
req
.
args
else
""
try
:
vid
=
int
(
req
.
args
[
b
'
id
'
][
0
].
decode
())
if
b
'
id
'
in
req
.
args
else
0
except
ValueError
:
vid
=
0
if
not
data
and
b
'
base64
'
in
req
.
args
:
data
=
base64
.
b64decode
(
req
.
args
[
b
'
base64
'
][
0
])
h
=
dht
.
InfoHash
(
uri
)
if
len
(
uri
)
==
40
else
dht
.
InfoHash
.
get
(
uri
.
decode
())
print
(
'
POST
'
,
h
,
data
)
req
.
setHeader
(
b
"
content-type
"
,
b
"
application/json
"
)
if
data
:
self
.
node
.
put
(
h
,
dht
.
Value
(
data
))
v
=
dht
.
Value
(
data
)
if
vid
!=
0
:
v
.
id
=
vid
v
.
user_type
=
user_type
self
.
node
.
put
(
h
,
v
)
return
json
.
dumps
({
'
success
'
:
True
}).
encode
()
else
:
req
.
setResponseCode
(
400
)
...
...
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