@@ -56,13 +56,17 @@ def register(request):
56
56
57
57
58
58
#get note
59
- @api_view (['GET ' ])
59
+ @api_view (['POST ' ])
60
60
@login_required
61
61
@csrf_exempt
62
62
def get_notes (request ):
63
- notes = Notes .objects .all ()
63
+ json_data = request .data
64
+ user_id = json_data ['user_id' ]
65
+ user = User .objects .get (id = user_id )
66
+ notes = Notes .objects .filter (user_id = user )
64
67
serializer = NoteSerializer (notes ,many = True )
65
- return JsonResponse (serializer .data ,safe = False )
68
+ # return JsonResponse(serializer.data,safe=False)
69
+ return Response ({'Message' :"all notes" , 'data' : serializer .data },status = status .HTTP_200_OK )
66
70
67
71
#add note
68
72
@api_view (['POST' ])
@@ -91,6 +95,7 @@ def delete_notes(request):
91
95
return Response ({'Message' :"Note has been deleted" },status = status .HTTP_200_OK )
92
96
93
97
98
+
94
99
#update note
95
100
@api_view (['POST' ])
96
101
@login_required
@@ -114,7 +119,13 @@ def get_questions(request):
114
119
json_data = request .data
115
120
note_id = json_data ['note_id' ]
116
121
number_of_questions = json_data ['number_of_questions' ]
122
+ # [props.showQuizPage.fib, props.showQuizPage.mcq, props.showQuizPage.tf]
123
+ types_of_questions = {"fib" : json_data ['types_of_questions' ][0 ],
124
+ "mcq" : json_data ['types_of_questions' ][1 ],
125
+ "tf" : json_data ['types_of_questions' ][2 ]}
117
126
note = Notes .objects .get (id = note_id )
127
+ print (types_of_questions )
128
+ print ("aagaya atleast yaha! " )
118
129
#url for ml server
119
130
ml_server_url = "localhost/questions/11"
120
131
data = requests .post (ml_server_url , data = {'note_text' : note .content , 'number_of_questions' : number_of_questions })
@@ -129,9 +140,11 @@ def get_questions(request):
129
140
def get_image_content (request ):
130
141
if request .method == 'POST' :
131
142
json_data = request .data
132
- number_of_questions = json_data ['number_of_questions' ]
143
+ # number_of_questions = json_data['number_of_questions']
144
+ number_of_questions = 7
133
145
img_data = request .FILES ['file' ].read ()
134
- img_string = base64 .b64encode (img_data )
146
+ print (img_data )
147
+ img_string = base64 .b64encode (img_data )
135
148
136
149
#url for ml server image to text
137
150
ml_server_url = "localhost/questions/3"
0 commit comments