def post(self):
        logging.info("oi")
        task_request = json.loads(self.request.body)

        task_record = TaskRecord(title=task_request.get('title'), description=task_request.get('description'))

        task_record.put()

        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(json.dumps(task_record.to_dict(), cls=DateEncoder))
    def get(self):
        tasks = TaskRecord.query().order(TaskRecord.date)
        tasks_json = []
        for task in tasks:
            tasks_json.append(task.to_dict())

        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(
            json.dumps(tasks_json, cls=DateEncoder))  # We need to use a custom DateEncoder to handle Dates in NDB
Exemple #3
0
    def get(self):
        tasks = TaskRecord.query().order(TaskRecord.date)
        tasks_json = []
        for task in tasks:
            tasks_json.append(task.to_dict())

        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(
            json.dumps(tasks_json, cls=DateEncoder)
        )  # We need to use a custom DateEncoder to handle Dates in NDB