RESTful Python for Java (Jersey) developer

java, jersey, python-2.7, rest

Solution

You may want to check the previous similar question: Recommendations of Python REST (web services) framework?

Python does not have a built-in REST framework, but I personally have had good experiences with Flask and Bottle.

It's very similar in use to Jersey (Bottle example):

@route('/')
@route('/hello/<name>')
def greet(name='Stranger'):
    return template('Hello {{name}}, how are you?', name=name)

Handling HTTP verbs:

@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        do_the_login()
    else:
        show_the_login_form()

Problem

BACKGROUND: I have a REST API implemented in Java using Jersey. My API uses four verbs: GET, POST, PUT, DELETE. I find developing REST APIs in java very easy and straight forward. eg here is an elaborate `hello` webservice (I say elaborate because there are easier ways, but this is more representative): ``` import javax.ws.rs.*; @Path("/myresource") public class MyResource{ @GET @Path("name/{name}") @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response sayHello(@PathParam("name") String name){ return Response.ok("Hello "+name).build(); } } ``` PROBLEM: I am learning python. I want to convert my Java Jersey REST API into python. Basically Jersey is Java's implementation of REST (aka JAX-RS: Java API for RESTful Web Services). Does python have a reference implementation of REST? If not, is there any implementation out there that comes close and would be easy to use for someone coming from Java-Jersey?

Original source

Related problems