File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,29 @@ def add_answer(questionId):
8282 return response
8383
8484
85+ @app .route ('/api/v1/questions/<int:questionId>' , methods = ['PATCH' ])
86+ def update_question (questionId ):
87+ request_data = request .get_json ()
88+ updated_question = dict ()
89+ ids = [question ['questionId' ] for question in questionsList ]
90+
91+ if questionId in ids :
92+ if "topic" in request_data :
93+ updated_question ["topic" ] = request_data ["topic" ]
94+ if "body" in request_data :
95+ updated_question ["body" ] = request_data ["topic" ]
96+
97+ for question in questionsList :
98+ if question ["questionId" ] == questionId :
99+ question .update (updated_question )
100+
101+ response = Response ('' , status = 204 )
102+ response .headers ['Location' ] = "/questions" + str (questionId )
103+ return response
104+
105+ response = Response (json .dumps (['Question not found' ]), status = 404 )
106+ return response
107+
85108
86109
87110def valid_question (questionObject ):
@@ -94,4 +117,5 @@ def valid_answer(answerObject):
94117 if 'Qn_Id' in answerObject and 'answerId' in answerObject and 'body' in answerObject :
95118 return True
96119 else :
97- return False
120+ return False
121+
You can’t perform that action at this time.
0 commit comments