Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 254 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recommendations of Python REST (web services) framework?

#1
Is there a list somewhere of recommendations of different Python-based REST frameworks for use on the serverside to write your own RESTful APIs? Preferably with pros and cons.

Please feel free to add recommendations here. :)
Reply

#2
I am not an expert on the python world but I have been using [django][1] which is an excellent web framework and can be used to create a restful framework.


[1]:

[To see links please register here]

Reply

#3
See [Python Web Frameworks][1] wiki.

You probably do not need the *full stack* frameworks, but the remaining list is still quite long.


[1]:

[To see links please register here]

Reply

#4
We're using [Django][1] for RESTful web services.

Note that -- out of the box -- Django did not have fine-grained enough authentication for our needs. We used the [Django-REST interface][2], which helped a lot. [We've since rolled our own because we'd made so many extensions that it had become a maintenance nightmare.]

We have two kinds of URL's: "html" URL's which implement the human-oriented HTML pages, and "json" URL's which implement the web-services oriented processing. Our view functions often look like this.

def someUsefulThing( request, object_id ):
# do some processing
return { a dictionary with results }

def htmlView( request, object_id ):
d = someUsefulThing( request, object_id )
render_to_response( 'template.html', d, ... )

def jsonView( request, object_id ):
d = someUsefulThing( request, object_id )
data = serializers.serialize( 'json', d['object'], fields=EXPOSED_FIELDS )
response = HttpResponse( data, status=200, content_type='application/json' )
response['Location']= reverse( 'some.path.to.this.view', kwargs={...} )
return response

The point being that the useful functionality is factored out of the two presentations. The JSON presentation is usually just one object that was requested. The HTML presentation often includes all kinds of navigation aids and other contextual clues that help people be productive.

The `jsonView` functions are all very similar, which can be a bit annoying. But it's Python, so make them part of a callable class or write decorators if it helps.

[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#5
I really like <a href="http://cherrypy.org/">CherryPy</a>. Here's an example of a restful web service:

import cherrypy
from cherrypy import expose

class Converter:
@expose
def index(self):
return "Hello World!"

@expose
def fahr_to_celc(self, degrees):
temp = (float(degrees) - 32) * 5 / 9
return "%.01f" % temp

@expose
def celc_to_fahr(self, degrees):
temp = float(degrees) * 9 / 5 + 32
return "%.01f" % temp

cherrypy.quickstart(Converter())

This emphasizes what I really like about CherryPy; this is a completely working example that's very understandable even to someone who doesn't know the framework. If you run this code, then you can immediately see the results in your web browser; e.g. visiting

[To see links please register here]

will display `122.0` in your web browser.
Reply

#6
Take a look at

- [Itty][1] ([blog post][5])
- [Bottle][2]
- [web.py][3]
- [juno][4]


[1]:

[To see links please register here]

"Itty"
[2]:

[To see links please register here]

"Bottle"
[3]:

[To see links please register here]

[4]:

[To see links please register here]

[5]:

[To see links please register here]

Reply

#7
I strongly recommend TurboGears or Bottle:

TurboGears:

- less verbose than django
- more flexible, less HTML-oriented
- but: less famous

Bottle:

- very fast
- very easy to learn
- but: minimalistic and not mature
Reply

#8
Here is a discussion in CherryPy docs on REST:

[To see links please register here]


In particular it mentions a built in CherryPy dispatcher called MethodDispatcher, which invokes methods based on their HTTP-verb identifiers (GET, POST, etc...).
Reply

#9
[Piston][1] is very flexible framework for wirting RESTful APIs for Django applications.


[1]:

[To see links please register here]

Reply

#10
In 2010, the Pylons and repoze.bfg communities "joined forces" to create <a href="http://pylonsproject.org/">Pyramid</a>, a web framework based most heavily on repoze.bfg. It retains the philosophies of its parent frameworks, and can be used for <a href="http://zhuoqiang.me/a/restful-pyramid">RESTful services</a>. It's worth a look.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through