-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from ImageMarkup/study-add-images
Create API endpoints to add additional images and multiple users to a study
- Loading branch information
Showing
11 changed files
with
189 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
############################################################################### | ||
# Copyright Kitware Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 ( the "License" ); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
############################################################################### | ||
|
||
import json | ||
|
||
import cherrypy | ||
import six | ||
|
||
from girder.api.rest import Resource | ||
|
||
|
||
class IsicResource(Resource): | ||
def _decodeParams(self, params): | ||
""" | ||
Decode POSTed or PUTed JSON parameters, from either | ||
"application/x-www-form-urlencoded" or "application/json" bodies. | ||
:param params: The "params" parameter from a Resource route handler. | ||
:type params: dict | ||
:return: The decoded parameters. | ||
:rtype: dict | ||
""" | ||
if cherrypy.request.headers['Content-Type'].split(';')[0] == \ | ||
'application/json': | ||
decodedParams = self.getBodyJson() | ||
else: | ||
decodedParams = {} | ||
for field, value in six.viewitems(params): | ||
try: | ||
decodedValue = json.loads(value) | ||
except ValueError: | ||
# Assume this was just a simple string; invalid JSON should | ||
# be caught later by type checking validation | ||
decodedValue = value | ||
decodedParams[field] = decodedValue | ||
return decodedParams |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.