4
0
This repository has been archived on 2020-07-25. You can view files and clone it, but cannot push or open issues or pull requests.
classification-service/classification_service/utils/require_decorators.py

17 lines
292 B
Python
Raw Permalink Normal View History

2020-04-15 00:33:06 +02:00
#!/usr/bin/env python3
2020-04-20 22:53:12 +02:00
from flask import request, abort
2020-04-15 00:33:06 +02:00
from functools import wraps
def json_required(f):
@wraps(f)
def call(*args, **kwargs):
if request.is_json:
return f(*args, **kwargs)
else:
abort(400, "JSON required")
return call