test

Dependencies:   EthernetNetIf HTTPServer mbed

Fork of HTTPServerHelloWorld by Donatien Garnier

Revision:
3:ce7861888719
Parent:
0:5630d7e58a0b
--- a/HTTPServerHelloWorld.cpp	Fri Jul 09 14:46:34 2010 +0000
+++ b/HTTPServerHelloWorld.cpp	Mon Nov 25 12:41:43 2013 +0000
@@ -1,26 +1,33 @@
 #include "mbed.h"
 #include "EthernetNetIf.h"
 #include "HTTPServer.h"
-
+Serial out(USBTX, USBRX);
 EthernetNetIf eth;  
 HTTPServer svr;
-
+LocalFileSystem local("local");
 DigitalOut led1(LED1);
 
 int main() {
-  printf("Setting up...\n");
+  out.printf("Setting up...\n");
   EthernetErr ethErr = eth.setup();
   if(ethErr)
   {
-    printf("Error %d in setup.\n", ethErr);
+    out.printf("Error %d in setup.\n", ethErr);
     return -1;
   }
-  printf("Setup OK\n");
+  out.printf("Setup OK\n");
+   
+  FILE *fp = fopen("/local/index.htm", "w");  // Open "out.txt" on the local file system for writing
+  fprintf(fp, "<html><head><title>Hello World online</title></head><body><h1>Hello World from Mbed NXP LPC1768!</h1></body></html>");
+  fclose(fp);
   
+  FSHandler::mount("/local/index.htm", "/"); //Mount /webfs path on web root path
+  
+     
   svr.addHandler<SimpleHandler>("/"); //Default handler
   svr.bind(80);
   
-  printf("Listening...\n");
+  out.printf("Listening...\n");
     
   Timer tm;
   tm.start();