def api_add_user(): user_details = request.get_json() user_details_object = Users(user_details) db_session.add(user_details_object) db_session.commit() return { "id": user_details_object.uid, "msg": "user created successfully" }, 201
def api_create_new_task(): # In post operation we first fetch the json received from client received_json = request.get_json() # Convert that Json into you object tasks_object = Tasks(received_json) tasks_object.tcreatedondate = datetime.now() db_session.add(tasks_object) db_session.commit() return {"id": tasks_object.tid, "msg": "task created"}, 201
def useradd(): form = FormCreateUser() user_data = [] if form.validate_on_submit(): user_data.append(form.username.data) user_data.append(form.email.data) new_user = Users(user_data) db_session.add(new_user) db_session.commit() flash('You have been logged in!', 'success') return redirect(url_for('get_all_users')) else: flash('Login Unsuccessful. Please check username and password', 'danger') return render_template('useradd.html', title='Add User', form=form)
def taskadd(): form = FormCreateTask() data = [] isdeleted = False isdone = False creationdate = datetime.now() print(creationdate) if form.validate_on_submit(): data.append(form.username.data) data.append(form.title.data) data.append(form.description.data) data.append(isdeleted) data.append(isdone) data.append(creationdate) new_task = Tasks(data) db_session.add(new_task) db_session.commit() print(data) flash('You have been logged in!', 'success') return redirect(url_for('get_all_tasks')) else: flash('Login Unsuccessful. Please check username and password', 'danger') return render_template('taskadd.html', title='Add Task', form=form)