44app = FastAPI ()
55tasks = []
66task_id_counter = 1
7- # выводим список всех полученных задач
7+ # we display a list of all received tasks.
88@app .get ("/tasks" )
99def get_tasks ():
1010 return tasks
11- # добавляем новую задачу, добавляем ее в список задач и увеличиваем счетчик id
11+ # We add a new task, add it to the task list, and increment the id counter.
1212@app .post ("/tasks" )
1313def create_task (name : str , condition : str = 'new' ):
1414 task = {'id' : task_id_counter , 'name' : name , 'condition' : condition }
1515 tasks .append (task )
1616 task_id_counter += 1
1717 return task
18- # обновляем задачу , в случае отсутствия задачи вызываем ошибку
18+ # We update the task; if the task is missing, we raise an error.
1919@app .put ("/tasks/{task_id}" )
2020def update_task (task_id : int , name :str , condition : str ):
2121 for task in tasks :
@@ -24,7 +24,7 @@ def update_task(task_id: int, name:str, condition: str):
2424 task [condition ] = condition
2525 return task
2626 raise HTTPException (status_code = 404 , detail = 'task not found' )
27- # ищем задачу по id, если находи - удаляем, если нет - вызываем ошибку
27+ # We search for a task by ID, if we find it, we delete it, if not, we raise an error
2828@app .delete ("/tasks/{task_id}" )
2929def delete_task (task_id : int ):
3030 for task in tasks :
0 commit comments