예제 #1
0
def run(host="localhost", user="******", password="******", database="opendkim", bindAddress='', bindPort=8000):
    "This program runs a web server to retrieve reputation data from the opendkim database"

    outputRegistry = OutputRegistry('application/reputon+json')
    outputRegistry.register('application/reputon+json', jsonDateFormatter)
    outputRegistry.register('text/html', jsonDateFormatter)
    api = SaratogaAPI(DKIM, DKIM_APIDef, serviceClass=Database(user=user, password=password, host=host, database=database),
                      outputRegistry=outputRegistry)
    api.run(port=bindPort)
예제 #2
0
def run(host="localhost",
        user="******",
        password="******",
        database="opendkim",
        bindAddress='',
        bindPort=8000):
    "This program runs a web server to retrieve reputation data from the opendkim database"

    outputRegistry = OutputRegistry('application/reputon+json')
    outputRegistry.register('application/reputon+json', jsonDateFormatter)
    outputRegistry.register('text/html', jsonDateFormatter)
    api = SaratogaAPI(DKIM,
                      DKIM_APIDef,
                      serviceClass=Database(user=user,
                                            password=password,
                                            host=host,
                                            database=database),
                      outputRegistry=outputRegistry)
    api.run(port=bindPort)
예제 #3
0
import json
from saratoga.api import SaratogaAPI

class PlanetAPI(object):
    class v1(object):
        def yearlength_GET(self, request, params):
            planetName = params["params"]["name"].lower()
            if planetName == "earth":
                return {"seconds": 31536000}
            elif planetName == "pluto":
                return {"seconds": 7816176000}

APIDescription = json.load(open("planets.json"))
myAPI = SaratogaAPI(PlanetAPI, APIDescription)
myAPI.run(port=8094)
예제 #4
0
파일: simple.py 프로젝트: hawkowl/saratoga
from saratoga.api import SaratogaAPI
import json

class ServiceClassExample(object):
    stuff = "foo"

class ExampleAPI(object):
    class v1(object):
        def example_GET(self, request, params):
            return self.stuff

api = SaratogaAPI(ExampleAPI, json.load(open("simple.json")), serviceClass=ServiceClassExample())
api.run()
예제 #5
0
from saratoga.api import SaratogaAPI
import json


class ServiceClassExample(object):
    stuff = "foo"


class ExampleAPI(object):
    class v1(object):
        def example_GET(self, request, params):
            return self.stuff


api = SaratogaAPI(ExampleAPI,
                  json.load(open("simple.json")),
                  serviceClass=ServiceClassExample())
api.run()