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
Schultz, Lucian
lab-traffic-mgmt
Commits
ab22aeb2
Commit
ab22aeb2
authored
May 10, 2021
by
Schultz, Lucian
Browse files
load_url in service.py edited
parent
72d42e58
Pipeline
#42697
passed with stages
in 1 minute and 53 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
space/service.py
View file @
ab22aeb2
...
...
@@ -5,7 +5,7 @@ import socket
import
json
# A very boring and basic space-service to demonstrate
# content-based traffic management.
# content-based traffic management.
role
=
os
.
environ
.
get
(
'ROLE'
,
'data'
)
astros_svc
=
os
.
environ
.
get
(
"ASTROS_SVC"
,
"astros"
)
...
...
@@ -25,11 +25,11 @@ def index():
def
load_url
(
url
,
headers
):
print
(
f
"Got these headers
{
dict
(
headers
)
}
"
)
h
=
{}
#
h = {
#
"User-Agent": headers['User-Agent'],
#
"Routing": headers.get('Routing', 'no')
#
}
#
h = {}
h
=
{
"User-Agent"
:
headers
[
'User-Agent'
],
"Routing"
:
headers
.
get
(
'Routing'
,
'no'
)
}
return
json
.
loads
(
requests
.
get
(
url
,
headers
=
h
,
allow_redirects
=
True
).
content
)
@
app
.
route
(
'/data'
)
...
...
Write
Preview
Supports
Markdown
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