Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
model_server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Christopher Randolph Rhodes
model_server
Commits
f7a78116
Commit
f7a78116
authored
9 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Drop none-valued query parameters by default
parent
83772a26
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!50
Release 2024.06.03
,
!46
Issue0038
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
model_server/clients/imagej/adapter.py
+10
-1
10 additions, 1 deletion
model_server/clients/imagej/adapter.py
with
10 additions
and
1 deletion
model_server/clients/imagej/adapter.py
+
10
−
1
View file @
f7a78116
...
...
@@ -13,18 +13,27 @@ HOST = '127.0.0.1'
PORT
=
6221
uri
=
'
http://{}:{}/
'
.
format
(
HOST
,
PORT
)
def
hit_endpoint
(
method
,
endpoint
,
params
=
None
,
body
=
None
):
def
hit_endpoint
(
method
,
endpoint
,
params
=
None
,
body
=
None
,
drop_none
=
True
):
"""
Python 2.7 implementation of HTTP client
:param method: (str) either
'
GET
'
or
'
PUT
'
:param endpoint: (str) endpoint of HTTP request
:param params: (dict) of parameters that are embedded in client request URL
:param body: (dict) of parameters that JSON-encoded and attached as payload in request
:param drop_none: (bool) remove (presumably optional) parameters with value equal to None
:return: (dict) of response status and content, formatted as dict if request is successful
"""
connection
=
httplib
.
HTTPConnection
(
HOST
,
PORT
)
if
not
method
in
[
'
GET
'
,
'
PUT
'
]:
raise
Exception
(
'
Can only handle GET and PUT requests
'
)
k_pop
=
[]
if
drop_none
:
for
k
,
v
in
params
.
items
():
if
v
is
None
:
k_pop
.
append
(
k
)
for
ki
in
k_pop
:
params
.
pop
(
ki
)
if
params
:
url
=
endpoint
+
'
?
'
+
urllib
.
urlencode
(
params
)
else
:
...
...
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