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

33,619

Solution 1

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.

Solution 2

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

Solution 3

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

Solution 4

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

Solution 5

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)
Share:
33,619
Rick
Author by

Rick

Updated on March 19, 2020

Comments

  • Rick
    Rick about 4 years

    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?