Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
callidus
Machina Callida
Commits
39e4f5d5
Commit
39e4f5d5
authored
May 19, 2020
by
Konstantin Schulz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
openAPI documentation is now accessible at /mc/api/v1.0/ui
parent
70e003f0
Pipeline
#11606
passed with stages
in 2 minutes and 59 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
18 deletions
+21
-18
mc_backend/mcserver/app/__init__.py
mc_backend/mcserver/app/__init__.py
+12
-14
mc_backend/mcserver/app/api/corpusListAPI.py
mc_backend/mcserver/app/api/corpusListAPI.py
+0
-2
mc_backend/tests.py
mc_backend/tests.py
+1
-1
mc_frontend/nginx.conf
mc_frontend/nginx.conf
+8
-1
No files found.
mc_backend/mcserver/app/__init__.py
View file @
39e4f5d5
...
...
@@ -61,17 +61,16 @@ def create_app(cfg: Type[Config] = Config) -> Flask:
return
app
def
full_init
(
app
:
Flask
,
is_csm
:
bool
)
->
None
:
def
full_init
(
app
:
Flask
,
cfg
:
Type
[
Config
]
=
Config
)
->
None
:
""" Fully initializes the application, including logging."""
if
is_csm
:
from
mcserver.app.services
import
DatabaseService
DatabaseService
.
init_db_update_info
()
DatabaseService
.
update_exercises
(
is_csm
=
is_csm
)
DatabaseService
.
init_db_corpus
()
if
not
app
.
config
[
"TESTING"
]:
from
mcserver.app.services.corpusService
import
CorpusService
CorpusService
.
init_graphannis_logging
()
start_updater
(
app
)
from
mcserver.app.services
import
DatabaseService
DatabaseService
.
init_db_update_info
()
DatabaseService
.
update_exercises
(
is_csm
=
True
)
DatabaseService
.
init_db_corpus
()
if
not
cfg
.
TESTING
:
from
mcserver.app.services.corpusService
import
CorpusService
CorpusService
.
init_graphannis_logging
()
start_updater
(
app
)
def
init_app_common
(
cfg
:
Type
[
Config
]
=
Config
,
is_csm
:
bool
=
False
)
->
Flask
:
...
...
@@ -91,14 +90,13 @@ def init_app_common(cfg: Type[Config] = Config, is_csm: bool = False) -> Flask:
if
is_csm
:
from
mcserver.app.services.databaseService
import
DatabaseService
DatabaseService
.
init_db_alembic
()
tables
:
List
[
str
]
=
[
Config
.
DATABASE_TABLE_ALEMBIC
,
Config
.
DATABASE_TABLE_CORPUS
,
Config
.
DATABASE_TABLE_EXERCISE
,
Config
.
DATABASE_TABLE_UPDATEINFO
]
if
any
(
not
db
.
engine
.
dialect
.
has_table
(
db
.
engine
,
x
)
for
x
in
tables
):
if
is_csm
or
cfg
.
TESTING
:
db
.
create_all
()
from
mcserver.app.services.textService
import
TextService
TextService
.
init_proper_nouns_list
()
TextService
.
init_stop_words_latin
()
full_init
(
app
,
is_csm
)
if
is_csm
:
full_init
(
app
,
cfg
)
return
app
...
...
mc_backend/mcserver/app/api/corpusListAPI.py
View file @
39e4f5d5
"""The corpus list API. Add it to your REST API to provide users with a list of metadata for available texts."""
from
datetime
import
datetime
from
connexion.lifecycle
import
ConnexionResponse
from
flask
import
Response
from
sqlalchemy.exc
import
OperationalError
,
InvalidRequestError
...
...
mc_backend/tests.py
View file @
39e4f5d5
...
...
@@ -758,7 +758,7 @@ class CsmTestCase(unittest.TestCase):
Mocks
.
app_dict
[
self
.
class_name
].
app
.
config
[
"TESTING"
]
=
False
with
patch
.
object
(
CorpusService
,
"init_graphannis_logging"
):
with
patch
.
object
(
mcserver
.
app
,
"start_updater"
)
as
updater_mock
:
full_init
(
Mocks
.
app_dict
[
self
.
class_name
].
app
,
True
)
full_init
(
Mocks
.
app_dict
[
self
.
class_name
].
app
)
self
.
assertEqual
(
updater_mock
.
call_count
,
1
)
Mocks
.
app_dict
[
self
.
class_name
].
app
.
config
[
"TESTING"
]
=
True
db
.
session
.
query
(
UpdateInfo
).
delete
()
...
...
mc_frontend/nginx.conf
View file @
39e4f5d5
...
...
@@ -32,10 +32,17 @@ http {
index
index.html
index.htm
;
# enable CORS so the cordova files (config.xml) can be accessed from other domains
add_header
Access-Control-Allow-Origin
*
;
rewrite
^(.*)mc-service(.*)^
http://localhost:5000
$2
last
;
try_files
$uri
$uri
/
/index.html
=
404
;
}
# dirty hack to redirect the OpenAPI requests for their schema definition
location
~
/openapi.json$
{
resolver
127
.0.0.11
valid=30s
;
set
$backend_host
mcserver
;
rewrite
/
(.*)
/mc/
$1
break
;
proxy_pass
http://
$backend_host
:
5000
;
}
location
/mc-service/
{
resolver
127
.0.0.11
valid=30s
;
set
$backend_host
mcserver
;
...
...
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