tiny web server in D

Dr.Smith ds at nomail.com
Thu Jul 14 09:37:51 PDT 2011


The program as such can regurgitate a web page provided these additional lines:

string webpage = "index.html";
string output = "HTTP/1.1 200 OK\r\n Content-Type: text/html; charset=UTF-8\r\n\r
\n" ~ to!string(read(webpage) ~ "\r\n";

This does not serve a page as localhost:port/webpage.html, but merely displays
output on localhost:port

I've been exploring std.socket for an efficient solution.  It might also be
desirable to get the program to open the port only on request.


More information about the Digitalmars-d-learn mailing list