[BangPypers] export methods from a python class as RESTful webservice calls

Noufal Ibrahim noufal at gmail.com
Thu Jun 23 13:11:33 CEST 2011

Umar Shah <umar43 at gmail.com> writes:

> Hello group,
> I have used Django, Pylons for different projects before but i want
> something minimal without overheads of MVC frameworks.
> say I have something like
> class X(object):
>   ...
>   def A(p1, p2,...):
>       ....
>       return {'state':x}
>   def B(p1, p2,..):
>       ....
>       return {'state':y}
> I want to expose calls to A and B over HTTP.
> Assuming I do not want any more features, I was wondering is what would be
> best/ efficient way to export methods A, B as RESTfull webservice calls.


You have quite a few options. 
1. Use the plain old SimpleHTTPServer module and write something to
   expose these calls. 
2. Use a microframework like web.py or flask. A complete flask or web.py
   app looks almost like the code you've pasted here. 
3. Use a framework explicitly meant for writing restful services
   (e.g. restish)


Everyone writes on the walls except me. -Said to be graffiti seen in Pompeii

More information about the BangPypers mailing list