0

Is there any tool/library for Python that will aid in interprocess communication, while keeping the API/client code easy to maintain?

I'm writing an application wherein I own both the server and the client portion, but I'd like to make it expandable to others via a REST interface (or something similarly accessible). Is my only options to write the boilerplate connective tissue for REST communication?

asked Mar 26, 2017 at 22:59

1 Answer 1

1

The REST interface should be implemented with small functions that call the actual Python API, which you will implement any way.

If you search here, on SO, the most frequent recommendation will be to use Flask to expose the REST interface.

There are libraries around that will try to turn the methods of a class into REST paths, and such, and those may save you a couple of hours on the onset, but cost you many hours down the road.

This morning I coded a backend service that way. The Requests calls to the external service are hidden by a module so the business logic doesn't know where the objects come from (ORM?), and the business logic produces objects that a simple Flask layer consumes to produce the JSON required by each matched URL.

@app.route("/api/users")
def users():
 return json_response(
 api.users(limit=request.args.get('limit', None)),
 )

A one-liner.

answered Mar 26, 2017 at 23:49
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.