On Thursday, 7 May 2015 at 08:25:30 UTC, Suliman wrote:
You're not setting a port.

add:
settings.port = 8080;

before listenHTTP();

then it'll work.

It's do not help :(

This should work, put it in your `app.d` file:

import vibe.d;

shared static this()
{

  auto settings = new HTTPServerSettings;
  settings.port = 8080;
  settings.bindAddresses = ["::1", "127.0.0.1"];

  auto router = new URLRouter;
  router.get("*", serveStaticFiles("./public/"));
  listenHTTP(settings, router);

  logInfo("Please open http://127.0.0.1:8080/ in your browser.");
}

Mind you, don't forget the `.` before the forward slash in serveStaticFiles("./public/").

Any file in the folder `public` should now be "navigate-able to" via:

http://127.0.0.1:8080/index.html
or
http://localhost/index.html

For starters, don't make your own custom main method. Just create a vibe.d project and paste the above code into app.d.

Later you can have a more sophisticated handling of requests.

Reply via email to