def insert(self, request, context):
     notaAux = notes_pb2.Note()
     notaAux.id = '5000'
     notaAux.title = request.title
     notaAux.content = request.content
     list_notas.append(notaAux)
     return notaAux
Beispiel #2
0
import grpc

import notes_pb2_grpc
import notes_pb2

channel = grpc.insecure_channel('localhost:50051')
client = notes_pb2_grpc.NoteServiceStub(channel)

newNote = notes_pb2.Note(title="New note", content="From Python")

client.Insert(newNote)
print(newNote)
import grpc
import time
import notes_pb2
import notes_pb2_grpc
from concurrent import futures

ONE_DAY_IN_SECONDS = 60 * 60 * 24

list_notas = []

for x in range(0, 10):
    notaAux = notes_pb2.Note()
    notaAux.id = str(x)
    notaAux.title = "Nota " + str(x)
    notaAux.content = "Contenido " + str(x)
    list_notas.append(notaAux)


class NOTE(notes_pb2_grpc.NoteServiceServicer):
    def list(self, request, context):
        return notes_pb2.NoteList(notes=list_notas)

    def insert(self, request, context):
        notaAux = notes_pb2.Note()
        notaAux.id = '5000'
        notaAux.title = request.title
        notaAux.content = request.content
        list_notas.append(notaAux)
        return notaAux

Beispiel #4
0
 def edit_note(self,data):
     message = notes_pb2.Note(id=data.id,todo=data.todo)
     return self.stub.Update(message)
Beispiel #5
0
 def add_note(self,data):
     message = notes_pb2.Note(todo=data.todo)
     return self.stub.Insert(message)
Beispiel #6
0
import notes_pb2
import notes_pb2_grpc
import grpc

e = notes_pb2.Empty()
nota = notes_pb2.Note()
nota.title = "Nota 5000"
nota.content = "Contenido 5000"


def run():
    channel = grpc.insecure_channel('localhost:50051')
    stub = notes_pb2_grpc.NoteServiceStub(channel)
    nota2 = stub.insert(nota)
    print(nota2)


if __name__ == '__main__':
    run()