Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
2f19496e
Commit
2f19496e
authored
Jan 08, 2021
by
Markus Scheidgen
Browse files
Unified the documentation paths for optimade and v1.
parent
fc32f513
Changes
3
Hide whitespace changes
Inline
Side-by-side
nomad/app_fastapi/main.py
View file @
2f19496e
...
...
@@ -17,7 +17,7 @@
#
from
fastapi
import
FastAPI
,
status
,
Request
from
fastapi.responses
import
JSONResponse
from
fastapi.responses
import
JSONResponse
,
RedirectResponse
from
fastapi.middleware.wsgi
import
WSGIMiddleware
import
traceback
...
...
@@ -32,8 +32,8 @@ logger = utils.get_logger(__name__)
app
=
FastAPI
(
openapi_url
=
'%s/api/v1/openapi.json'
%
config
.
services
.
api_base_path
,
docs_url
=
'%s/api/v1/docs'
%
config
.
services
.
api_base_path
,
redoc_url
=
'%s/api/v1/redoc'
%
config
.
services
.
api_base_path
,
docs_url
=
'%s/api/v1/
extensions/
docs'
%
config
.
services
.
api_base_path
,
redoc_url
=
'%s/api/v1/
extensions/
redoc'
%
config
.
services
.
api_base_path
,
swagger_ui_oauth2_redirect_url
=
'%s/api/v1/docs/oauth2-redirect'
%
config
.
services
.
api_base_path
,
title
=
'NOMAD API'
,
...
...
@@ -114,6 +114,14 @@ app = FastAPI(
'''
))
async
def
redirect_to_docs
(
req
:
Request
):
return
RedirectResponse
(
'%s/api/v1/extensions/docs'
%
config
.
services
.
api_base_path
)
app
.
add_route
(
'%s/api/v1'
%
config
.
services
.
api_base_path
,
redirect_to_docs
,
include_in_schema
=
False
)
app
.
add_route
(
'%s/api/v1/'
%
config
.
services
.
api_base_path
,
redirect_to_docs
,
include_in_schema
=
False
)
@
app
.
on_event
(
'startup'
)
async
def
startup_event
():
from
nomad
import
infrastructure
...
...
nomad/app_fastapi/optimade/__init__.py
View file @
2f19496e
...
...
@@ -12,10 +12,9 @@ sys.modules['optimade.server.logger'] = importlib.import_module('nomad.app_fasta
# patch optimade base path
from
nomad
import
config
,
utils
# nopep8
from
optimade.server.config
import
CONFIG
# nopep8
CONFIG
.
root_path
=
"
%s/optimade
"
%
config
.
services
.
api_base_path
CONFIG
.
root_path
=
'
%s/optimade
'
%
config
.
services
.
api_base_path
from
optimade.server
import
main
as
optimade
# nopep8
from
optimade.server.main
import
app
as
optimade_app
# nopep8
from
optimade.server.routers
import
structures
# nopep8
# remove all the test data
...
...
@@ -59,3 +58,6 @@ def general_exception(request, exc, status_code=500, **kwargs):
setattr
(
exception_handlers
,
'general_exception'
,
general_exception
)
# "export" the app object
optimade_app
=
optimade
.
app
nomad/cli/admin/admin.py
View file @
2f19496e
#
# Copyright The NOMAD Authors.
#
...
...
@@ -24,7 +25,7 @@ import elasticsearch
import
sys
import
threading
from
nomad
import
processing
as
proc
,
search
,
datamodel
,
infrastructure
,
utils
,
config
from
nomad
import
processing
as
proc
,
search
,
infrastructure
,
utils
,
config
from
nomad.cli.cli
import
cli
...
...
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