Вопрос

is a web application build with cherryPy like I found in http://blaag.haard.se/Simple-REST-ful---ish--exposure-of-Python-APIs/ really a restful webservice?

import cherrypy
def requesthandler(*pathargs, **kwargs):
    cherrypy.response.status = "whatever"
    return "Not implemented"
class PyRest(object):
    def index(self, *args, **kwargs):
        return requesthandler(*args, **kwargs)
    index.exposed = True
CONF = {
    'global': {
        'server.socket_host': '0.0.0.0',
        'server.socket_port': 8888,
    }
}
if __name__ == '__main__':
    ROOT = PyRest()
    cherrypy.quickstart(ROOT, '/', CONF)
def application(environ, start_response):
  cherrypy.tree.mount(PyRest(), '/', None)
  return cherrypy.tree(environ, start_response)

I ask it because is only implemented the index and when you call to the web app, a post request is shown in the log.

Это было полезно?

Решение

No, it's not RESTful. There is a good tutorial in CherryPy docs: Creating a RESTful API.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top