Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- с create у тебя не заладилось)
- ошибка при компиляции
- привела 2 рабочих варианта и линки полезные
- @app.route('/todo/api/v1.0/tasks', methods = ['POST'])
- @auth.login_required
- def create_task():
- if not request.json or not 'title' in request.json:
- abort(400)
- id = 1
- if len(tasks) != 0: id = tasks[-1]['id'] + 1
- task = {
- 'id': id,
- 'title': request.json['title'],
- 'description': request.json.get('description', ""),
- 'done': False
- }
- tasks.append(task)
- return jsonify( { 'task': make_public_task(task) } ), 201
- @app.route('/todo/api/v1.0/tasks', methods = ['POST'])
- @auth.login_required
- def create_task():
- if not request.json or not 'title' in request.json:
- abort(400)
- task = {
- 'id': 1 if len(tasks) == 0 else tasks[-1]['id'] + 1,
- 'title': request.json['title'],
- 'description': request.json.get('description', ""),
- 'done': False
- }
- tasks.append(task)
- return jsonify( { 'task': make_public_task(task) } ), 201
- https://lancelote.gitbooks.io/intermediate-python/content/book/ternary_operators.html
- https://lancelote.gitbooks.io/intermediate-python/content/book/comprehensions.html (dict абстракции)
- http://www.diveintopython.net/native_data_types/index.html#odbchelper.dict
- *****************************************
- @Test
- public void testCreate() {
- TasksApi.create(new Task("Give lesson", "Lesson description", false, TasksApi.uri + "/3"));
- assertTasks(DEFAULT_TASKS[0], DEFAULT_TASKS[1], new Task("Give lesson", "Lesson description", false, TasksApi.uri + "/3"));
- }
- /*
- вынеси new Task("Give lesson", "Lesson description", false, TasksApi.uri + "/3") - в переменную
- и дважды ее используй
- тут получится )
- и тут
- testUpdate()
- */
Advertisement
Add Comment
Please, Sign In to add comment