Skip to content

Commit 8a55224

Browse files
Merge pull request #31 from Geode-solutions/feat_validate_request
feat(functions): validate_request function
2 parents 2a328b1 + 124c2f1 commit 8a55224

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/opengeodeweb_back/geode_functions.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,15 @@ def extension_from_filename(filename):
234234
return os.path.splitext(filename)[1][1:]
235235

236236

237-
def form_variables(form, variables_array):
238-
variables_dict = {}
237+
def validate_request(request, variables_array):
238+
json_data = request.get_json(force=True, silent=True)
239+
240+
if json_data is None:
241+
flask.abort(400, f"No json sent")
242+
239243
for variable in variables_array:
240-
if form.get(variable) is None:
244+
if variable not in json_data.keys():
241245
flask.abort(400, f"No {variable} sent")
242-
else:
243-
variables_dict[variable] = form.get(variable)
244-
return variables_dict
245246

246247

247248
def geographic_coordinate_systems(geode_object: str):

0 commit comments

Comments
 (0)