Exemple #1
0
def worldquery(request):
    if request.method == 'GET':
        try:
            data = json.loads(
                open('qirana_backend/dataset/world-2query.json').read())
        except 'FileNotFoundError':
            print("Error in reading file")

        jsonData = json.dumps(data)
        datasets = dataset_meta.objects.all()
        serializer = nameSerializer(datasets, many=True)
        return JsonResponse(data, safe=False)
Exemple #2
0
def list(request):
    if request.method == 'GET':
        try:
            data = json.loads(
                open('C:/Users/Yashbidasaria/Desktop/datasets.json').read())
        except 'FileNotFoundError':
            print("Error in reading file")

        jsonData = json.dumps(data)
        datasets = dataset_meta.objects.all()
        serializer = nameSerializer(datasets, many=True)
        return JsonResponse(data, safe=False)
    elif request.method == 'POST':
        data = json.loads(request.body)
        with open('C:/Users/Yashbidasaria/Desktop/datasets.json',
                  'w') as outfile:
            json.dump(data, outfile)
        return JsonResponse(request.POST)