0

I want to version my APIs (written in python: using cherrypy- version 13.1.0), but simply giving the alias as /v1/apiName throws a "path not found" error. Is there any way to do this using cherryPy. (I did consider using FastAPI for this, but for my particular usecase, cherryPy outperformed FastAPI in load tests). Example of my API:

Class APIClass:

   @cherrypy.expose(alias="v1/apiName")
   @cherrypy.tools.json_in()
   @cherrypy.tools.json_out()
   def does_stuff():
      **do stuff**
baggy696
  • 37
  • 7

2 Answers2

0

Yes, it's definitely possible with CherryPy, you can do something like this in your def and carry on from there:

    @cherrypy.expose
    def client(self, *url_parts, **params):

Hope this helps.

  • thanks for the reply. Would you mind showing this solution on the example API that i added in the question? – baggy696 Jun 19 '22 at 05:29
0

The best solution for me in this scenario is using cherrypy.popargs. Leaving Sylvian Hellegourach's answer here: Friendly URL for a REST WebService with CherryPy

baggy696
  • 37
  • 7