sviddo commited on
Commit
685a923
1 Parent(s): 48a206d

change places of endpoint-handling functions to preserve consistent order

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -176,8 +176,8 @@ async def get_hint(request: Request):
176
  return JSONResponse(hints.generate_hint(question_numbers, right_answer, number_correct, number_incorrect, level, hints_used))
177
 
178
 
179
- @app.post("/numbers_by_level")
180
- async def get_numbers_by_level(request: Request):
181
  """Generates a hint and returns it as response along with hint data
182
 
183
  Input
@@ -187,21 +187,23 @@ async def get_numbers_by_level(request: Request):
187
  }
188
 
189
  Output
190
- context: dict - three generated numbers for specified level
191
  {
 
192
  "current_number": 10,
193
  "ordinal_number": 2,
194
- "times": 1
195
  }
196
  """
197
  data_dict = await request.json()
198
  message_data = ast.literal_eval(data_dict.get('message_data', '').get('message_body', ''))
199
  level = message_data['level']
200
- return JSONResponse(questions.generate_numbers_by_level(level))
201
 
 
202
 
203
- @app.post("/generate_question")
204
- async def generate_question(request: Request):
 
205
  """Generates a hint and returns it as response along with hint data
206
 
207
  Input
@@ -211,16 +213,14 @@ async def generate_question(request: Request):
211
  }
212
 
213
  Output
214
- context: dict - the information for the current state
215
  {
216
- "question": "Let's count up by 2s. What number is next if we start from 10",
217
  "current_number": 10,
218
  "ordinal_number": 2,
219
- "answer": 12
220
  }
221
  """
222
  data_dict = await request.json()
223
  message_data = ast.literal_eval(data_dict.get('message_data', '').get('message_body', ''))
224
  level = message_data['level']
225
-
226
- return JSONResponse(questions.generate_question_data(level)['question'])
 
176
  return JSONResponse(hints.generate_hint(question_numbers, right_answer, number_correct, number_incorrect, level, hints_used))
177
 
178
 
179
+ @app.post("/generate_question")
180
+ async def generate_question(request: Request):
181
  """Generates a hint and returns it as response along with hint data
182
 
183
  Input
 
187
  }
188
 
189
  Output
190
+ context: dict - the information for the current state
191
  {
192
+ "question": "Let's count up by 2s. What number is next if we start from 10",
193
  "current_number": 10,
194
  "ordinal_number": 2,
195
+ "answer": 12
196
  }
197
  """
198
  data_dict = await request.json()
199
  message_data = ast.literal_eval(data_dict.get('message_data', '').get('message_body', ''))
200
  level = message_data['level']
 
201
 
202
+ return JSONResponse(questions.generate_question_data(level)['question'])
203
 
204
+
205
+ @app.post("/numbers_by_level")
206
+ async def get_numbers_by_level(request: Request):
207
  """Generates a hint and returns it as response along with hint data
208
 
209
  Input
 
213
  }
214
 
215
  Output
216
+ context: dict - three generated numbers for specified level
217
  {
 
218
  "current_number": 10,
219
  "ordinal_number": 2,
220
+ "times": 1
221
  }
222
  """
223
  data_dict = await request.json()
224
  message_data = ast.literal_eval(data_dict.get('message_data', '').get('message_body', ''))
225
  level = message_data['level']
226
+ return JSONResponse(questions.generate_numbers_by_level(level))