Browse Source

fix serve root index html

221V 2 weeks ago
parent
commit
78f7e3ee61
2 changed files with 6 additions and 5 deletions
  1. 1 1
      README.md
  2. 5 4
      vtest/source/app.d

+ 1 - 1
README.md

@@ -8,7 +8,7 @@ $ cd <FOLDER_NAME>
 $ make c
 
 
-http://127.0.0.1:8080/index.html
+http://127.0.0.1:8080/
 
 
 $ ldc2 -v

+ 5 - 4
vtest/source/app.d

@@ -19,10 +19,11 @@ void main(){
   //fsettings.serverPathPrefix = "/static";
   
   auto router = new URLRouter;
-  router.get("/", &index);
+  //router.get("/", &index);
   ////router.get("static/*", serverStaticFiles("public/", fsettings) );
   
-  //router.get("/", staticTemplate!"index.html"); // todo fix
+  //router.get("/", staticTemplate!"index.html");
+  router.get("/", serveStaticFile("public/index.html") );
   router.get("/ws", handleWebSockets(&ws_handle) );
   router.get("*", serveStaticFiles("public/"));
   
@@ -45,11 +46,11 @@ void ws_handle(scope WebSocket sock){
   }
 }
 
-
+/*
 void index(HTTPServerRequest req, HTTPServerResponse res){
   res.writeBody("Hello, World!");
 }
-
+*/
 
 /*
 void hello(HTTPServerRequest req, HTTPServerResponse res){