RESTful Python Developer for Java (Jersey)

BACKGROUND:

I have a REST API implemented in Java using Jersey. My API uses four verbs: GET, POST, PUT, DELETE. I find the development of the REST API in java very simple and straightforward.

for example, this is a complex hello web service (I speak in detail, because there are simpler ways, but it 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 Java REST API to python.

Basically, Jersey is an implementation of Java REST (aka JAX-RS: Java API for RESTful web services). Does python have a reference REST implementation? If not, is there some kind of implementation that is approaching and will be easy to use for someone from Java-Jersey?

+4
source share
1 answer

You might want to check out a previous similar question: Python REST (web services) framework recommendations?

Python does not have a built-in REST structure, but I had a good impression of Flask and Bottle .

This is very similar to using a jersey (bottle example):

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

Processing HTTP verbs:

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

Source: https://habr.com/ru/post/1447366/


All Articles