开发者

How to read parameters from GET request in CherryPy?

How to read parameters from GET request in CherryPy ? I generate request from JQuery like

$.get(
    "http://localhost:8080/temp",
    "{a:10}",
    function(d开发者_Python百科ata) { alert(data); },
    "html"
);

and I have class temp with @cherrypy.expose function index(self). How to extract data from GET request ?


@cherrypy.expose
def index(self, param)

where param is your GET param


As virhilo mentioned, you can take named parameters in with your method.

Also, you can read cherrypy.request.params.


With both POST and GET (and PUT, PATCH, etc...) you can use:

cherrypy.request.params.get(key_name)

Where key_name is the key name you want to get.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜