Adding additionnal common request handlers to http.server

The standard library module http.server already has 2 request handlers, with SimpleHTTPRequestHandler and CGIHTTPRequestHandler, the first serves files from a directory, and the second executes CGI scripts. Two new handlers could be included in the standard library : - WebhookRequestHandler : Would spin up an HTTP server that one could connect webhooks to. Webhooks are really useful when dealing with APIs. So far, the third-party package, requests, is used when interacting with Web APIs, but there is nothing in the standard library that implements the webhook standard. - APIRequestHandler : This can be more controversial, especially with third-party packages like Flask, starlette, and django that will be much more powerful and secure than this, but this handler would be used to spin up a server that would make it easy to serve a simple restful API. I have already implemented both handlers in pure python (without third-party packages obviously), I'm just wondering if it's a good idea to make it a PEP, and implement these handlers as part of the python standard library.

On Mon, Aug 24, 2020 at 11:26 PM Simon <simon.bordeyne@gmail.com> wrote:
Not really in favour of "API" as a name. If you want a simple RESTful API framework, I'd call it something with REST in the name. But I'm not sure that that's needed, since you'd quickly outgrow a simple class and need to go for Flask/Django/etc. Webhooks are very tempting. There's a lot to be said for properly implementing this protocol in the standard library. It might be a bit harder, though, since it basically wants asynchronous or threaded I/O. Maybe this would be a good addition to asyncio? ChrisA

On Mon, Aug 24, 2020 at 11:26 PM Simon <simon.bordeyne@gmail.com> wrote:
Not really in favour of "API" as a name. If you want a simple RESTful API framework, I'd call it something with REST in the name. But I'm not sure that that's needed, since you'd quickly outgrow a simple class and need to go for Flask/Django/etc. Webhooks are very tempting. There's a lot to be said for properly implementing this protocol in the standard library. It might be a bit harder, though, since it basically wants asynchronous or threaded I/O. Maybe this would be a good addition to asyncio? ChrisA
participants (2)
-
Chris Angelico
-
Simon