DPP/DLT functionality #36
12
dpp/views.py
12
dpp/views.py
|
@ -1,3 +1,4 @@
|
||||||
|
import logging
|
||||||
from django.views.generic.edit import View
|
from django.views.generic.edit import View
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
|
|
||||||
|
@ -6,10 +7,16 @@ from dpp.models import Proof
|
||||||
from dpp.api_dlt import ALGORITHM
|
from dpp.api_dlt import ALGORITHM
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger('django')
|
||||||
|
|
||||||
|
|
||||||
class ProofView(View):
|
class ProofView(View):
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
timestamp = kwargs.get("proof_id")
|
timestamp = kwargs.get("proof_id")
|
||||||
|
for p in Proof.objects.filter():
|
||||||
|
logger.error(p.timestamp)
|
||||||
|
|
||||||
proof = Proof.objects.filter(timestamp=timestamp).first()
|
proof = Proof.objects.filter(timestamp=timestamp).first()
|
||||||
if not proof:
|
if not proof:
|
||||||
return JsonResponse({}, status=404)
|
return JsonResponse({}, status=404)
|
||||||
|
@ -31,6 +38,9 @@ class ProofView(View):
|
||||||
'@context': ['https://ereuse.org/proof0.json'],
|
'@context': ['https://ereuse.org/proof0.json'],
|
||||||
'data': data,
|
'data': data,
|
||||||
}
|
}
|
||||||
return JsonResponse(d, status=200)
|
response = JsonResponse(d, status=200)
|
||||||
|
response["Access-Control-Allow-Origin"] = "*"
|
||||||
|
return response
|
||||||
|
|
||||||
return JsonResponse({}, status=404)
|
return JsonResponse({}, status=404)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue