Skip to content

Instantly share code, notes, and snippets.

View ashish-mj's full-sized avatar
🏠
Working from home

Ashish M J ashish-mj

🏠
Working from home
View GitHub Profile
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
from concurrent import futures
import grpc
import helloworld_pb2
import helloworld_pb2_grpc
class Greeter(helloworld_pb2_grpc.GreeterServicer):
def SayHello(self, request, context):
return helloworld_pb2.HelloReply(message="Hello, %s!" % request.name)
def run():
import grpc
import helloworld_pb2
import helloworld_pb2_grpc
def run():
with grpc.insecure_channel("localhost:50051") as channel:
stub = helloworld_pb2_grpc.GreeterStub(channel)
response = stub.SayHello(helloworld_pb2.HelloRequest(name="World"))
print("Greeter client received: " + response.message)
from flask_graphql import GraphQLView
from graphene import Schema,ObjectType,String, Argument
from flask import Flask
app = Flask(__name__)
class Query(ObjectType):
hello = String(name = Argument(String, default_value = "World"))
def resolve_hello(self, info, name):
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return "Hello World!"
if __name__ == '__main__':
app.run()
from flask_graphql import GraphQLView
from graphene import Schema
from flask import Flask
from gql.query import Query
from gql.mutation import Mutation
app = Flask(__name__)
schema = Schema(query=Query,mutation=Mutation)
from graphene import Mutation,Float,String,Field,ObjectType,Boolean,Int
from gql.type import EmployeeObject
from db.couchbase import dbClient
import os
class AddEmployee(Mutation):
class Arguments:
firstName = String(required=True)
lastName = String(required=True)
age = Int(required=True)
from graphene import ObjectType,List,Field,String
from gql.type import EmployeeObject
from db.couchbase import dbClient
class Query(ObjectType):
employeeList = List(EmployeeObject)
employee = Field(EmployeeObject,id=String(required="True"))
@staticmethod
def resolve_employeeList(root,info):
from graphene import ObjectType, String,Int,Float
class EmployeeObject(ObjectType):
id = String()
firstName = String()
lastName = String()
age = Int()
email = String()
phone = Float()
sex = String()
from couchbase.auth import PasswordAuthenticator
from couchbase.cluster import Cluster
from couchbase.exceptions import CouchbaseException, DocumentNotFoundException
from couchbase.options import ClusterOptions
import os
from dotenv import load_dotenv
class CouchbaseClient(object):
def __init__(self, host, bucket, scope, collection, username, pw):
self.host = host