[Tutor] Option on How to create web Interface

Danny Yoo dyoo at hashcollision.org
Thu May 22 02:27:33 CEST 2014


As a web server, you would not even be trying to open a file on disk.
You've most likely got the network socket as a file-like object in
hand: you'd probably write directly to that file-like object and avoid
touching any disk whatsoever.  You want to avoid touching disk if
possible, especially on high-traffic web sites.

See: https://wiki.python.org/moin/BaseHttpServer  for an example.  If
we use the standard library's web server, there's a "wfile" that's the
file-like object that we can write to.
(https://docs.python.org/3/library/http.server.html?highlight=wfile#http.server.BaseHTTPRequestHandler.wfile)

If we use the standard library, what might be unfortunately confusing
is that our output is depending on a field in the "request" object.
Personally, I think that's a design flaw of the standard library web
server.

Many other web server frameworks will provide a "response" argument
that is conceptually separate from the "request" argument.


More information about the Tutor mailing list