Exemplo n.º 1
0
 def setUp(self):
     resource = provider_for_twisted(GreetingProvider())
     factory = Site(resource)
     self.port = reactor.listenTCP(0, factory, interface="127.0.0.1")
     self.client = None
Exemplo n.º 2
0
 def setUp(self):
     resource = provider_for_twisted(GreetingProvider())
     factory = Site(resource)
     self.port = reactor.listenTCP(0, factory, interface="127.0.0.1")
     self.client = None
Exemplo n.º 3
0
from twisted.internet import reactor
from twisted.web.server import Site

from webservices. async import provider_for_twisted
from webservices.models import Provider

API_KEYS = {
    'pubkey': 'privkey',  # your keys here
}


class HelloProvider(Provider):
    def get_private_key(self, public_key):
        return API_KEYS.get(public_key)

    def provide(self, data):
        name = data.get('name', 'world')
        return {'greeting': u'hello %s' % name}


resource = provider_for_twisted(HelloProvider())

site = Site(resource)
reactor.listenTCP(8000, site)
reactor.run()
Exemplo n.º 4
0
from twisted.internet import reactor
from twisted.web.server import Site

from webservices.async import provider_for_twisted
from webservices.models import Provider


API_KEYS = {
    'pubkey': 'privkey',  # your keys here
}


class HelloProvider(Provider):
    def get_private_key(self, public_key):
        return API_KEYS.get(public_key)

    def provide(self, data):
        name = data.get('name', 'world')
        return {'greeting': u'hello %s' % name}


resource = provider_for_twisted(HelloProvider())

site = Site(resource)
reactor.listenTCP(8000, site)
reactor.run()