def list(): redis = sessions.Sessions() redis.add(datetime.now()) datastore = notes.Notes() if request.method == 'POST': note = request.data result = datastore.create(note) return note, status.HTTP_201_CREATED return datastore.find()
def list(): redis = sessions.Sessions() redis.add(str(datetime.now())) mongodb = notes.Notes() if request.method == 'POST': note = request.data result = mongodb.create(note) # Se adicionó para poder manejar ObjectID note['_id'] = str(note['_id']) return note, status.HTTP_201_CREATED return mongodb.find()
def notes_detail(key): mongodb = notes.Notes() if request.method == 'PUT': note = request.data mongodb.update(key, note) return note elif request.method == 'DELETE': mongodb.delete(key) return '', status.HTTP_204_NO_CONTENT # request.method == 'GET' note = mongodb.findOne(key) if not note: raise exceptions.NotFound() else: return note return jsonify(key)