Creating a minimal HTTP server with asyncio

While I am familiar with HTTP servers and event loops, I am having some problems understanding the Python asyncio internals .

As a training exercise, I am trying to write a minimal HTTP server (only an echo request of the request method, URI, headers and body) without additional dependencies. I looked at aiohttp and aiowsgi for reference, but not understanding what is happening there - partly because of the perceived complexity of protocols, transport, etc. a little overwhelming. So I’m stuck right now because I don’t know where to start.

Is it naive to expect that these are just a few lines of code to establish a connection, consume an incoming text stream and send another text stream?

+6
source share
1 answer

You can take a look at picoweb as an example of a very simple (and very limited) HTTP server.

But of course, when you try to implement a full-featured web server, you will get something like aiohttp - HTTP is a complex (albeit complex) standard.

+4
source

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


All Articles