# (c) cavaliba.com  - data/api - ping.py

"""
/api/ (index, always denied) and /api/ping/ (unauthenticated liveness check).

Method inventory: index, ping.
"""

from django.views.decorators.csrf import csrf_exempt

import app_data.api.helper as helper


#  ----------------------------------------------------------------------------
# /api/
#  ----------------------------------------------------------------------------
@csrf_exempt
def index(request):
    """Root of the API: always denied (no anonymous browsing of /api/)."""
    return helper.send_denied()


#  ----------------------------------------------------------------------------
# /api/ping/
# NO AUTH
#  ----------------------------------------------------------------------------
@csrf_exempt
def ping(request):
    """Unauthenticated liveness check; always returns {"status": "OK"}."""

    reply = {"status": "OK"}
    # time.sleep(5)
    return helper.send_response(request, reply, 200)
