30 lines
731 B
Python
30 lines
731 B
Python
from http.client import NO_CONTENT, CREATED
|
|
|
|
from flask import make_response, jsonify
|
|
|
|
from flaschengeist.utils.datetime import from_iso_format
|
|
|
|
|
|
def get_filter_args():
|
|
"""
|
|
Get filter parameter from request
|
|
returns: FROM, TO, LIMIT, OFFSET, DESCENDING
|
|
"""
|
|
from flask import request
|
|
|
|
return (
|
|
request.args.get("from", type=from_iso_format),
|
|
request.args.get("to", type=from_iso_format),
|
|
request.args.get("limit", type=int),
|
|
request.args.get("offset", type=int),
|
|
"descending" in request.args,
|
|
)
|
|
|
|
|
|
def no_content():
|
|
return make_response(jsonify(""), NO_CONTENT)
|
|
|
|
|
|
def created(obj=None):
|
|
return make_response(jsonify(obj if obj is not None else ""), CREATED)
|