librelist archives

« back to archive

question about the Flask-XML-RPC extension

question about the Flask-XML-RPC extension

From:
mat --
Date:
2010-11-03 @ 17:19
Hello,

I would like to use the Flask-XML-RPC extension. I am trying to run the
'Simple Example' code seen on http://packages.python.org/Flask-XML-RPC/

from flask import Flask

from flaskext.xmlrpc import XMLRPCHandler, Fault
app = Flask(__name__)
handler = XMLRPCHandler('api')handler.connect(app, '/api')
@handler.registerdef hello(name="world"):
    if not name:
        raise Fault("unknown_recipient", "I need someone to greet!")
    return "Hello, %s!" % name
app.run()

I am getting a 'Not Found' error when visiting http://127.0.0.1:5000 and
a 'Method Not Allowed' error when visiting http://127.0.0.1:5000/api

I am also getting an error when running the python code seen in the 'Using
Your API' section

>>> import xmlrpclib
>>> server = xmlrpclib.ServerProxy('http://localhost:5000/')
>>> server.hello()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.6/xmlrpclib.py", line 1243, in request
    headers
xmlrpclib.ProtocolError: <ProtocolError for localhost:5000/: 404 NOT FOUND>


Are there any requirements or configuration steps other than what is
described in the doc?

Can someone share a sample file showing how to use the XMLRPC extension?

Thanks

Mat
*
*

Re: [flask] question about the Flask-XML-RPC extension

From:
Robert Mela
Date:
2010-11-03 @ 22:03
could not decode message

Re: [flask] question about the Flask-XML-RPC extension

From:
mat --
Date:
2010-11-04 @ 06:49
I am able to run the code and get an XML-RPC response.

Thanks, Robert for your explanations and your code sample!

Mat

On Thu, Nov 4, 2010 at 12:03 AM, Robert Mela <rmela@rcn.com> wrote:

>  Going a little further on my last reply, the following code prints "Hello,
> foo!" to the console.
>
>
> import xmlrpclib
>
> proxy = xmlrpclib.ServerProxy('http://localhost:7000/api')
> print proxy.system.listMethods()
> try:
>         resp=proxy.hello('foo')
>         print resp
> except xmlrpclib.Fault, err:
>         print "A fault occurred"
>         print "Fault code: %d" % err.faultCode
>         print "Fault string: %s" % err.faultString
>
>
>
> On 11/3/10 1:19 PM, mat -- wrote:
>
> Hello,
>
>  I would like to use the Flask-XML-RPC extension. I am trying to run the
> 'Simple Example' code seen on http://packages.python.org/Flask-XML-RPC/
>
>
>  from flask import Flask
>
>  from flaskext.xmlrpc import XMLRPCHandler, Fault
> app = Flask(__name__)
> handler = XMLRPCHandler('api')handler.connect(app, '/api')
> @handler.registerdef hello(name="world"):
>     if not name:
>         raise Fault("unknown_recipient", "I need someone to greet!")
>     return "Hello, %s!" % name
> app.run()
>
>  I am getting a 'Not Found' error when visiting http://127.0.0.1:5000 and
> a 'Method Not Allowed' error when visiting http://127.0.0.1:5000/api
>
>  I am also getting an error when running the python code seen in the
> 'Using Your API' section
>
>   >>> import xmlrpclib
>  >>> server = xmlrpclib.ServerProxy('http://localhost:5000/')
>  >>> server.hello()
>  Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
>    File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
>      return self.__send(self.__name, args)
>    File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
>      verbose=self.__verbose
>    File "/usr/lib/python2.6/xmlrpclib.py", line 1243, in request
>      headers
>  xmlrpclib.ProtocolError: <ProtocolError for localhost:5000/: 404 NOT
> FOUND>
>
>
>  Are there any requirements or configuration steps other than what is
> described in the doc?
>
>  Can someone share a sample file showing how to use the XMLRPC extension?
>
>  Thanks
>
>  Mat
> *
> *
>
>
>
>
>
>

Re: [flask] question about the Flask-XML-RPC extension

From:
Robert Mela
Date:
2010-11-03 @ 21:58
could not decode message