33

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?

1

6 Answers 6

25

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

13

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.

6

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())
1
  • 1
    Not to mention, @tools.json_in() and @tools.json_out() in recent versions.
    – fumanchu
    Oct 30, 2011 at 14:35
2

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()
1

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)
0

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.

3
  • In fact, it'll be even easier since they have native SDKs for iOS. You don't even need to know how to use a REST API and handle JSON encoding/decoding etc. You just work with native objects and save them to the platform.
    – jimothy
    Nov 30, 2011 at 2:01
  • the topic is specific to a Python framework. Parse does not support use of Python. In fact, if you want anything server side logic beyond CRUD functions, you will need to write in Java.
    – iksnae
    Jan 20, 2014 at 23:14
  • 1
    Parse is also discontinued now. FB shut it down.
    – Praxiteles
    May 6, 2016 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.