ScoDoc-PE/app/api/__init__.py
ivan 2ffcc503cb Apogée:
- corrige affichage état (filtres/comptes)
- affichage et modification période semset (+ API).
- export résultat annuel BUT.
2023-04-16 05:32:21 +02:00

52 lines
1.3 KiB
Python

"""api.__init__
"""
from flask import Blueprint
from flask import request
from app.scodoc import sco_utils as scu
from app.scodoc.sco_exceptions import ScoException
api_bp = Blueprint("api", __name__)
api_web_bp = Blueprint("apiweb", __name__)
# HTTP ERROR STATUS
API_CLIENT_ERROR = 400 # erreur dans les paramètres fournis par le client
@api_bp.errorhandler(ScoException)
@api_bp.errorhandler(404)
def api_error_handler(e):
"erreurs API => json"
return scu.json_error(404, message=str(e))
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
from app.api import tokens
from app.api import (
absences,
billets_absences,
departements,
etudiants,
evaluations,
formations,
formsemestres,
jury,
logos,
partitions,
semset,
users,
)