예제 #1
0
def launch_bottle(registry):
    import bottle

    # Create a bottle instance and register some routes
    app = bottle.Bottle()

    xmlbuilder = XmlBuilder()
    xmlbuilder.xslt_url = "/featured.xsl"

    @app.route(xmlbuilder.xslt_url)
    def xslt():
        bottle.response.headers['Content-Type'] = 'application/xml'
        fn = os.path.dirname(__file__) + "/featured.xsl"
        print fn, __file__
        with open(fn) as src:
            return src.read()

    @app.route("/")
    def index():
        """Show the complete registry
        """
        bottle.response.headers['Content-Type'] = 'application/xml'
        return xmlbuilder.build(registry)

    @app.route("/methods/<path:path>")
    def call_method(path):
        """Call some method offered by the registry
        """
        bottle.response.headers['Content-Type'] = 'application/xml'
        kwargs = dict(bottle.request.query.items())
        return xmlbuilder.build(registry.methods[path](**kwargs))

    bottle.run(app, host='0.0.0.0', port=8082, reloader=True, debug=True)
예제 #2
0
def launch_bottle(registry):
    import bottle

    # Create a bottle instance and register some routes
    app = bottle.Bottle()

    xmlbuilder = XmlBuilder()
    xmlbuilder.xslt_url = "/featured.xsl"

    @app.route(xmlbuilder.xslt_url)
    def xslt():
        bottle.response.headers['Content-Type'] = 'application/xml'
        fn = os.path.dirname(__file__) + "/featured.xsl"
        print fn, __file__
        with open(fn) as src:
            return src.read()

    @app.route("/")
    def index():
        """Show the complete registry
        """
        bottle.response.headers['Content-Type'] = 'application/xml'
        return xmlbuilder.build(registry)

    @app.route("/methods/<path:path>")
    def call_method(path):
        """Call some method offered by the registry
        """
        bottle.response.headers['Content-Type'] = 'application/xml'
        kwargs = dict(bottle.request.query.items())
        return xmlbuilder.build(registry.methods[path](**kwargs))

    bottle.run(app, host='0.0.0.0', port=8082, reloader=True, debug=True)