php - how to fill a form inside cherrypy web service using curl -
i have cerrypy service running well, contains form has textarea, input text transformed re within same service , gives transformed text in screen, thing need send info command line, i've tried curl next documentation found here: http://curl.haxx.se/docs/httpscripting.html#forms_explained, can not create work:
the form this:
<form method="post" action="nmt"> <div><table width=100% bgcolor="d2cac1"><tr><td> <textarea class="richtextbox" name="contents" style="width:100%;height:300px"> </textarea> </td></tr></table></div> <a title="unificar"><input type="submit" value=" trapümün " /></a> </form>
and function this:
#define form function def nmt(self, contents=none): if not contents: homecoming """<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>nmt - norwirin mapudungun trapümfe</title></head> <body><font face=arial>inserte el texto para unificar<br><a href=.>inténtelo de nuevo</a></fon> </body></html>"""
i've tried this:
curl --data-urlencode "contents=zomo" http://www.chandia.net:8080 curl --data "contents=zomo" http://www.chandia.net:8080 curl --data "contents=zomo&submit=%20trapümün%20" http://89.140.140.36:8080
i've changed post seek this:
curl "http://www.chandia.net:8080?contents=zomo" curl "http://www.chandia.net:8080?contents=zomo&trapümün" curl "http://www.chandia.net:8080?contents=zomo&%20trapümün%20" curl "http://www.chandia.net:8080?contents=zomo&submit=%20trapümün%20"
the results changes bit says:
<body> <h2>400 bad request</h2> <p>unexpected body parameters: contents</p> <pre id="traceback">traceback (most recent phone call last): file "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 656, in respond response.body = self.handler() file "/usr/lib/python2.7/dist-packages/cherrypy/lib/encoding.py", line 188, in __call__ self.body = self.oldhandler(*args, **kwargs) file "/usr/lib/python2.7/dist-packages/cherrypy/_cpdispatch.py", line 40, in __call__ raise sys.exc_info()[1] httperror: (400, 'unexpected body parameters: contents')
any suggestions, or maybe there way it....?
thanks in advance
your handler definition must include following...
def nmt(self, contents)
or
def nmt(self, *args, **kwargs)
edit: you'll need specific handler in url.
curl --data-urlencode "contents=zomo" http://www.chandia.net:8080/nmt
hope helps!
php forms curl python-3.x cherrypy
No comments:
Post a Comment