2020-04-13 21:14:06 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from flask import request, current_app, abort
|
|
|
|
|
|
|
|
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
|
2020-10-02 03:28:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
def multipart_required(f):
|
|
|
|
@wraps(f)
|
|
|
|
def call(*args, **kwargs):
|
|
|
|
|
|
|
|
if request.form:
|
|
|
|
return f(*args, **kwargs)
|
|
|
|
else:
|
|
|
|
abort(400, "multipart/form-data required")
|
|
|
|
|
|
|
|
return call
|