This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service Greeter { | |
rpc SayHello (HelloRequest) returns (HelloReply) {} | |
} | |
message HelloRequest { | |
string name = 1; | |
} | |
message HelloReply { | |
string message = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
app = Flask(__name__) | |
@app.route('/') | |
def hello(): | |
return "Hello World!" | |
if __name__ == '__main__': | |
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from graphene import ObjectType, String,Int,Float | |
class EmployeeObject(ObjectType): | |
id = String() | |
firstName = String() | |
lastName = String() | |
age = Int() | |
email = String() | |
phone = Float() | |
sex = String() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder