Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hpc-team
sshshare_ws
Commits
51530759
Commit
51530759
authored
Feb 21, 2018
by
Chris Hines
Browse files
add endpoints to enable ip detection
parent
381595e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
sshshare_ws/endpoints.py
View file @
51530759
...
...
@@ -22,6 +22,20 @@ class ShareGetAPI(Resource):
data
=
json
.
loads
(
sd
.
value
)
return
data
class
ShareGetComponentAPI
(
Resource
):
def
get
(
self
,
component
,
key
):
import
json
logger
=
logging
.
getLogger
()
logger
.
debug
(
"get data for key {}"
.
format
(
key
))
try
:
sd
=
ShareData
.
query
.
get
(
key
)
except
:
return
{}
logger
.
debug
(
sd
.
value
)
data
=
json
.
loads
(
sd
.
value
)
return
data
[
component
]
class
ShareStoreAPI
(
Resource
):
...
...
@@ -50,5 +64,15 @@ class ShareStoreAPI(Resource):
logger
.
debug
(
traceback
.
format_exc
())
return
key
class
GetIP
(
Resource
):
def
get
(
self
):
if
not
request
.
headers
.
getlist
(
"X-Forwarded-For"
):
ip
=
request
.
remote_addr
else
:
ip
=
request
.
headers
.
getlist
(
"X-Forwarded-For"
)[
0
]
return
ip
api
.
add_resource
(
ShareStoreAPI
,
'/share/'
,
endpoint
=
'share_store_ep'
)
api
.
add_resource
(
ShareGetAPI
,
'/share/<key>'
,
endpoint
=
'share_get_ep'
)
api
.
add_resource
(
ShareGetComponentAPI
,
'/sharecomp/<component>/<key>'
,
endpoint
=
'share_get_component_ep'
)
api
.
add_resource
(
GetIP
,
'/getip/'
,
endpoint
=
'getip_ep'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment