Source

pyrest / pyrest / integration / cherry.py

Diff from to

File pyrest/integration/cherry.py

 
 class PyRest(object):
     def __init__(self, api):
+        self._api = api
         self._handlers = get_handlers(api)
         
     def index(self):
-        return "Awesome API..."
+        return "HTTP access to %s available at <a href='/api'>/api</a><br/> %s" % (self._api.__name__, self._api.__doc__)
 
     def api(self, resource, *pathargs, **kwargs):
         method = cherrypy.request.method.lower()
 
 
 
-if __name__ == '__main__':
-    from pyrest.examples import hg
+def start(api, port=8888, host='0.0.0.0'):
     CONF = {
-    'global': {
-        'server.socket_host': '0.0.0.0',
-        'server.socket_port': 8888,
+      'global': {
+        'server.socket_host': host,
+        'server.socket_port': port,
     }}
 
-    ROOT = PyRest(hg)
+    ROOT = PyRest(api)
 
     cherrypy.quickstart(ROOT, '/', CONF)
     
-#Not actually working right now
+#Not actually tested
 def application(environ, start_response):
-  cherrypy.tree.mount(PyRest(), '/', None)
+  cherrypy.tree.mount(PyRest(API), '/', None)
   return cherrypy.tree(environ, start_response)