Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
d592def9
Commit
d592def9
authored
May 23, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
harmonize json response syntax + safer for arrays than jsonify
parent
0d64ee4a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
main.py
services/main.py
+18
-4
No files found.
services/main.py
View file @
d592def9
...
...
@@ -31,7 +31,7 @@ from json import dumps
from
datetime
import
timedelta
from
urllib.parse
import
unquote
from
flask
import
Flask
,
render_template
,
request
,
\
redirect
,
url_for
,
session
,
jsonify
redirect
,
url_for
,
session
,
Response
from
flask_login
import
fresh_login_required
,
login_required
,
\
current_user
,
login_user
,
logout_user
...
...
@@ -217,7 +217,11 @@ def aggs_api():
search_filter_str
=
search_filter
,
hapax_threshold
=
hap_thresh
)
return
jsonify
(
result
)
return
Response
(
response
=
dumps
(
result
),
status
=
200
,
mimetype
=
"application/json"
)
else
:
raise
TypeError
(
"aggs API query is missing 'field' argument"
)
...
...
@@ -250,7 +254,12 @@ def graph_api():
# (less modular but a lot faster)
graphdb
.
extract
(
scholars
)
return
dumps
(
graphdb
.
buildJSON
(
graphdb
.
Graph
))
return
(
Response
(
response
=
dumps
(
graphdb
.
buildJSON
(
graphdb
.
Graph
)),
status
=
200
,
mimetype
=
"application/json"
)
)
else
:
raise
TypeError
(
"graph API query is missing qtype (should be 'filters' or 'uid')"
)
...
...
@@ -270,7 +279,12 @@ def user_api():
if
request
.
args
[
'op'
]
==
"exists"
:
if
'email'
in
request
.
args
:
email
=
sanitize
(
request
.
args
[
'email'
])
return
(
dumps
({
'exists'
:
dbcrud
.
email_exists
(
email
)}))
return
(
Response
(
response
=
dumps
({
'exists'
:
dbcrud
.
email_exists
(
email
)}),
status
=
200
,
mimetype
=
"application/json"
)
)
else
:
raise
TypeError
(
"user API query is missing the operation to perform (eg op=exists)"
)
...
...
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