On Tue, Aug 25, 2020 at 7:15 PM Christopher Barker <pythonchb@gmail.com> wrote:
On Tue, Aug 25, 2020 at 8:11 AM Simon <simon.bordeyne@gmail.com> wrote:
I find that flask's approach to this is quite pythonic. It's also relatively easy to use and explain.
This is a good point, I think you distracted a bit earlier by saying it would be familiar to flask users. That's true, but not the point. Rather, we are going for, as you say, a pythonic, simple, easy to use and explain API. And this one is inspired by flask, which is a good thing, as flask is widely used and excepted, and has a reputation for being fairly easy to get started with.opriate for quick prototyping.

Personally I'm fine with just using third party libraries for this stuff, but in terms of whether this is Pythonic, the example has this:

     @RESTRequestHandler.route('/get/<obj_id:int>', methods=['GET'])
     def get_obj(request, obj_id):

I think it should be written as:

     @RESTRequestHandler.route('/get/{obj_id}', methods=['GET'])
     def get_obj(request, obj_id: int):

The former API is what Flask does and it makes sense because it's an old library. Nowadays type annotations are possible and make more sense. This is somewhat inspired by FastAPI which is also well liked: https://fastapi.tiangolo.com/#example. The curly brackets make a bit more sense to me as well but that's not really the point.