Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DataCatalog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
eFlows4HPC WP2
DataCatalog
Commits
99b48b25
Commit
99b48b25
authored
3 years ago
by
Christian Boettcher
Browse files
Options
Downloads
Patches
Plain Diff
redirect to index.html if accept header has text/html before application/json
parent
0fda2b89
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!3
Update .gitlab-ci.yml
Pipeline
#72164
passed
3 years ago
Stage: test
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apiserver/main.py
+22
-2
22 additions, 2 deletions
apiserver/main.py
with
22 additions
and
2 deletions
apiserver/main.py
+
22
−
2
View file @
99b48b25
...
@@ -13,6 +13,7 @@ from fastapi.responses import JSONResponse
...
@@ -13,6 +13,7 @@ from fastapi.responses import JSONResponse
from
fastapi.security
import
OAuth2PasswordBearer
,
OAuth2PasswordRequestForm
from
fastapi.security
import
OAuth2PasswordBearer
,
OAuth2PasswordRequestForm
from
pydantic
import
UUID4
from
pydantic
import
UUID4
from
starlette.responses
import
RedirectResponse
from
.config
import
ApiserverSettings
from
.config
import
ApiserverSettings
from
.security
import
(
ACCESS_TOKEN_EXPIRES_MINUTES
,
JsonDBInterface
,
Token
,
from
.security
import
(
ACCESS_TOKEN_EXPIRES_MINUTES
,
JsonDBInterface
,
Token
,
...
@@ -72,13 +73,32 @@ async def login_for_access_token(user=Depends(my_auth)):
...
@@ -72,13 +73,32 @@ async def login_for_access_token(user=Depends(my_auth)):
return
{
"
access_token
"
:
access_token
,
"
token_type
"
:
"
bearer
"
}
return
{
"
access_token
"
:
access_token
,
"
token_type
"
:
"
bearer
"
}
@app.get
(
"
/
"
,
response_model
=
List
[
dict
[
str
,
str
]])
@app.get
(
"
/
"
,
response_model
=
List
[
dict
[
str
,
str
]])
async
def
get_types
():
async
def
get_types
(
request
:
Request
=
None
):
"""
"""
list types of data locations, currently datasets
list types of data locations, currently datasets
(will be provided by the pillars) and targets (possible storage
(will be provided by the pillars) and targets (possible storage
locations for worklfow results or similar)
locations for worklfow results or similar)
"""
"""
return
[{
element
.
value
:
"
/
"
+
element
.
value
}
for
element
in
LocationDataType
]
accept_header
=
request
.
headers
[
'
Accept
'
]
accept_json
=
"
application/json
"
accept_html
=
"
text/html
"
default_return
=
[{
element
.
value
:
"
/
"
+
element
.
value
}
for
element
in
LocationDataType
]
redirect_return
=
RedirectResponse
(
url
=
'
/index.html
'
)
# uses first of json and html that is in the accept header; returns json if neither is found
json_pos
=
accept_header
.
find
(
accept_json
)
html_pos
=
accept_header
.
find
(
accept_html
)
if
json_pos
==
-
1
:
json_pos
=
len
(
accept_header
)
if
html_pos
==
-
1
:
html_pos
=
len
(
accept_header
)
if
html_pos
<
json_pos
:
return
redirect_return
else
:
return
default_return
@app.get
(
"
/{location_data_type}
"
)
@app.get
(
"
/{location_data_type}
"
)
async
def
list_datasets
(
location_data_type
:
LocationDataType
):
async
def
list_datasets
(
location_data_type
:
LocationDataType
):
...
...
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