2021-09-09 12:49:23 +02:00
|
|
|
"""api.__init__
|
|
|
|
"""
|
|
|
|
|
|
|
|
from flask import Blueprint
|
2021-12-22 00:35:58 +01:00
|
|
|
from flask import request
|
2021-09-09 12:49:23 +02:00
|
|
|
|
|
|
|
bp = Blueprint("api", __name__)
|
|
|
|
|
2021-12-22 00:35:58 +01:00
|
|
|
|
|
|
|
def requested_format(default_format="json", allowed_formats=None):
|
|
|
|
"""Extract required format from query string.
|
|
|
|
* default value is json. A list of allowed formats may be provided
|
|
|
|
(['json'] considered if not provided).
|
|
|
|
* if the required format is not in allowed list, returns None.
|
|
|
|
|
|
|
|
NB: if json in not in allowed_formats, format specification is mandatory.
|
|
|
|
"""
|
|
|
|
format_type = request.args.get("format", default_format)
|
|
|
|
if format_type in (allowed_formats or ["json"]):
|
|
|
|
return format_type
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
2021-10-28 00:52:23 +02:00
|
|
|
from app.api import tokens
|
2021-12-22 00:35:58 +01:00
|
|
|
from app.api import sco_api
|
|
|
|
from app.api import logos
|