Sunday, March 14, 2004

When I need to serve up a few files for friends or try out some CGIs, XML-RPC, etc. I generally just fire up the PythonCard webserver sample. However, I find the following single line at a command prompt to be quite appealing for an instant web server.

    python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"

It works on any OS where you have Python installed and since you can cd (change directory) to the dir you want to serve files from before running the command you don't have to mess with config files or moving files before serving them up. If you alias the command or make a batch file you won't have to remember the whole line. Here's an example run on my Mac.

[solo:~/] altis% python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"
Serving HTTP on port 8000 ...
localhost - - [14/Mar/2004 09:27:09] "GET / HTTP/1.1" 200 -
localhost - - [14/Mar/2004 09:27:28] "GET / HTTP/1.1" 200 -


Note that this blog entry was revised after a discussion on Simon Brunning's blog.

10:03:59 AM    comment []

  Thursday, February 06, 2003

Shipping the prototype by Jon Udell at InfoWorld says "Let's promote scripting languages to the status they deserve"
12:43:15 PM    comment []

  Thursday, June 13, 2002

Mark Pilgrim's article about web services in Python contains one important bit that is often overlooked by people implementing web services with XML-RPC, the listMethods extension. The Python XML-RPC ServerProxy Objects documentation explains each method: listMethods(), methodSignature(), and methodHelp().

listMethods() and its companions provide much of the same information for an XML-RPC service as WSDL does for a SOAP service; everyone that runs an XML-RPC service should provide these methods. There is no need to define any additional standards, we already have a solution. Of course, the information provided is human readable, not machine readable, so if we wanted a more machine readable form, we could define some companion methods that always output XML. WSDL is not really human readable and I haven't seen any human readable SOAP service description.

XML-RPC in Python on O'Reilly ONLamp shows how these methods are utilized by meerkat.

12:42:18 PM    comment []

SOAP WSDL Verifiers and Analyzers

If you're writing client-side code and SOAP messages to talk to a web service described by a WSDL service, you'll probably benefit from seeing how one or more of the sites below parses the WSDL for a given service. If you're using a scripting language such as Python, the display of function calls and argument lists with appropriate namespace and soapaction is quite useful.

This is a follow-up to my earlier post about frustrations with WSDL and SOAP interop.

12:34:17 PM    comment []

  Wednesday, June 12, 2002

XML-RPC server in PythonCard 0.6.7

A new release of PythonCard should be out in the next couple of days. You can download it from cvs now if you don't want to wait. Among the many new samples is a GUI front-end to the web server that comes with the Python Standard Libraries. In addition to serving files, the webserver sample can do CGI, so it is a great way to get a web server up quickly on your desktop; all you have to do is double-click the script. Several example CGI scripts are included with the server.

I added Mark Pilgrim's PyWebServices scripts, so the webserver can act as an XML-RPC server too. After starting up the webserver sample you can test the XML-RPC server capabilities by running the radioclient sample, which automatically shows the shell and imports the xmlrpclib module. Then try this in the shell:

>>> server = xmlrpclib.Server('http://localhost/cgi-bin/')
>>> server.system.listMethods()
{'sample.helloWorld()': 'None', 'examples.getStateName(stateIndex)': 'None',
'system.listMethods()': 'None'}
>>> server.sample.helloWorld()
'Hello World!'
>>> server.examples.getStateName(1)
>>> server.examples.getStateName(50)

1:29:22 PM    comment []