[vibe.d] showing images

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 26 05:42:09 PDT 2016


doctype html
html
     body
         -foreach(s; images)
             // it doesn't seem to like #{s} or !{s}
             img(src=s)

----------
shared static this()
{
     auto router = new URLRouter;
     router.registerWebInterface(new CamController);

     auto settings = new HTTPServerSettings;
     settings.port = 8081;
     settings.bindAddresses = ["::1", "127.0.0.1"];
     listenHTTP(settings, router);


}
class Controller
{
     void index(HTTPServerRequest req, HTTPServerResponse res)
     {
         auto images = dirEntries("public/images",SpanMode.breadth)
                         .map!(f=> f.name).array;
         writeln(images); // ["public/images/testprog.jpg"]
         res.render!("index.dt",images);
     }
  }

What am I missing? I just get a 404 for the image.


More information about the Digitalmars-d-learn mailing list