What Python framework for a REST/JSON web service with no front end?

Question:

I need to create a Python REST/JSON web service for an iOS app to interact with. There will be no front end on the web.

What will be the fastest, most lightweight framework to use for this? Learning curve to implement also considered?

From the research I’ve done Django-Tastypie or Djanjo-Piston look like the best options, with Tastypie winning because the codebase is being maintained actively?

Asked By: Rick

||

Answers:

If I were you I would use web.py that is really convenient to do that kind of rapid prototyping of lightweight REST applications.
Check out this snippet from the home page:

import web

urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello:        
    def GET(self, name):
        if not name: 
            name = 'World'
        return 'Hello, ' + name + '!'

if __name__ == "__main__":
    app.run()
Answered By: lc2817

When it comes to lightweight, CherryPy is pretty up there.

import cherrypy

class HelloWorld(object):
    def index(self):
        return "Hello World!"
    index.exposed = True

cherrypy.quickstart(HelloWorld())
Answered By: Amber

At Pycon Australia, Richard Jones compared the most popular lightweight web frameworks. Bottle came out on top. Here is the full presentation.

Answered By: Raymond Hettinger

In general, I think you’ll find web2py to be one of the easiest frameworks to set up, learn, and use. web2py makes it very easy to generate JSON (just add a .json extension), and it now includes new functionality to automatically create RESTful web services to access database models. In particular, check out the parse_as_rest and smart_query functionality.

If you need any help, ask on the mailing list.

Answered By: Anthony

You might also want to check out Parse. They are free to use right now, and will give you a nice REST API for you mobile apps.

However, as @iksnar points out, you don’t write anything in Python, or anything at all for the backend. If you need to have the backend running in Python on your own servers I am a big fan of TastyPie if you are using Django already and the Django ORM already.

Answered By: Gourneau

Take a look to flask and its extension flask-restful

from flask import Flask
from flask.ext import restful

app = Flask(__name__)
api = restful.Api(app)

class HelloWorld(restful.Resource):
    def get(self):
        return {'hello': 'world'}

api.add_resource(HelloWorld, '/')

if __name__ == '__main__':
    app.run(debug=True)
Answered By: user1823890