def post(self):
     datasetForm = DatasetForm(request.form)
     user = current_user
     datasetObj = {"title": datasetForm.title.data,
                   'description': datasetForm.description.data,
                   "created_at": datetime.now(pytz.timezone('US/Eastern')).strftime('%Y-%m-%d %H:%M:%S'),
                   'user_id': current_user.id
                   }
     datasetValue = getValues(datasetForm.values.data)
     dataset = DatasetModel(**datasetObj)
     dataset.save_to_db(datasetValue)
     return redirect("http://localhost:8081/")
 def put(self, id):
     data = CalculationRoute.parser.parse_args()
     dataset = DatasetModel.findById(id)
     if dataset:
         dataset.modified_db_value(data['title'],data['description'],getValues(data['values']))
     else:
         datasetObj = {"title": data['title'],
                       'description': data['description'],
                       "created_at": datetime.now(pytz.timezone('US/Eastern')).strftime('%Y-%m-%d %H:%M:%S'),
                       'user_id': 1
                       }
         dataset = DatasetModel(**datasetObj)
         dataset.save_to_db(getValues(data['values']))
     return Response(response=json.dumps({"message": "dataset successfully edited"}),status=200,mimetype="application/json")
 def delete(self, id):
     dataset = DatasetModel.findById(id)
     if dataset:
         schema = DatasetSchema()
         deletedDataset = schema.dump(dataset)
         dataset.delete_from_db()
         message = {"dataset": deletedDataset, "message" : "dataset has successufully deleted"}
         jsonResponse = json.dumps({**message})
         return Response(response=jsonResponse,status=200, mimetype="application/json")
 def get(self,id):
     dataset = DatasetModel.findById(id)
     values = dataset.getDataSet()
     schema = DatasetSchema()
     datasetSchema= schema.dump(dataset)
     valuesJson = {"values":values}
     basicstats = {'calculation': basicStatisic(values)}
     mergeObj = {**datasetSchema, **valuesJson, **basicstats}
     return Response(response=json.dumps(mergeObj), status=200, mimetype="application/json")