Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
6bc1ef94
Commit
6bc1ef94
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Add api blueprint.
parent
93330c0e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/__init__.py
+3
-0
3 additions, 0 deletions
app/__init__.py
app/api/__init__.py
+5
-0
5 additions, 0 deletions
app/api/__init__.py
app/api/views.py
+67
-0
67 additions, 0 deletions
app/api/views.py
with
75 additions
and
0 deletions
app/__init__.py
+
3
−
0
View file @
6bc1ef94
...
@@ -24,6 +24,9 @@ def create_app(config_name):
...
@@ -24,6 +24,9 @@ def create_app(config_name):
scheduler
.
init_app
(
app
)
scheduler
.
init_app
(
app
)
scheduler
.
start
()
scheduler
.
start
()
from
.api
import
api
as
api_blueprint
app
.
register_blueprint
(
api_blueprint
,
url_prefix
=
'
/api
'
)
from
.auth
import
auth
as
auth_blueprint
from
.auth
import
auth
as
auth_blueprint
app
.
register_blueprint
(
auth_blueprint
,
url_prefix
=
'
/auth
'
)
app
.
register_blueprint
(
auth_blueprint
,
url_prefix
=
'
/auth
'
)
...
...
This diff is collapsed.
Click to expand it.
app/api/__init__.py
0 → 100644
+
5
−
0
View file @
6bc1ef94
from
flask
import
Blueprint
api
=
Blueprint
(
'
api
'
,
__name__
)
from
.
import
views
This diff is collapsed.
Click to expand it.
app/api/views.py
0 → 100644
+
67
−
0
View file @
6bc1ef94
from
flask
import
jsonify
from
flask_login
import
current_user
,
login_required
from
.
import
api
@api.route
(
'
/v1.0/corpora
'
)
@login_required
def
corpora
():
corpora
=
[]
for
corpus
in
current_user
.
corpora
.
all
():
corpora
.
append
({
'
id
'
:
corpus
.
id
,
'
creation_date
'
:
corpus
.
creation_date
.
timestamp
(),
'
description
'
:
corpus
.
description
,
'
title
'
:
corpus
.
title
})
return
jsonify
(
corpora
)
@api.route
(
'
/v1.0/corpora/<int:corpus_id>
'
)
@login_required
def
corpus
(
corpus_id
):
corpus
=
current_user
.
corpora
.
filter_by
(
id
=
corpus_id
).
first
()
if
not
corpus
:
'''
This should return 404
'''
return
jsonify
(
None
)
return
jsonify
({
'
id
'
:
corpus
.
id
,
'
creation_date
'
:
corpus
.
creation_date
,
'
description
'
:
corpus
.
description
,
'
title
'
:
corpus
.
title
})
@api.route
(
'
/v1.0/jobs
'
)
@login_required
def
jobs
():
jobs
=
[]
for
job
in
current_user
.
jobs
.
all
():
jobs
.
append
({
'
id
'
:
job
.
id
,
'
creation_date
'
:
job
.
creation_date
.
timestamp
(),
'
description
'
:
job
.
description
,
'
end_date
'
:
job
.
end_date
.
timestamp
()
if
job
.
end_date
else
None
,
'
mem_mb
'
:
job
.
mem_mb
,
'
n_cores
'
:
job
.
n_cores
,
'
service
'
:
job
.
service
,
'
service_args
'
:
job
.
service_args
,
'
service_version
'
:
job
.
service_version
,
'
status
'
:
job
.
status
,
'
title
'
:
job
.
title
})
return
jsonify
(
jobs
)
@api.route
(
'
/v1.0/jobs/<int:job_id>
'
)
@login_required
def
job
(
job_id
):
job
=
current_user
.
jobs
.
filter_by
(
id
=
job_id
).
first
()
if
not
job
:
'''
This should return 404
'''
return
jsonify
(
None
)
return
jsonify
({
'
id
'
:
job
.
id
,
'
creation_date
'
:
job
.
creation_date
.
timestamp
(),
'
description
'
:
job
.
description
,
'
end_date
'
:
job
.
end_date
.
timestamp
()
if
job
.
end_date
else
None
,
'
mem_mb
'
:
job
.
mem_mb
,
'
n_cores
'
:
job
.
n_cores
,
'
service
'
:
job
.
service
,
'
service_args
'
:
job
.
service_args
,
'
service_version
'
:
job
.
service_version
,
'
status
'
:
job
.
status
,
'
title
'
:
job
.
title
})
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