test

Dependencies:   EthernetNetIf HTTPServer mbed

Fork of HTTPServerHelloWorld by Donatien Garnier

Files at this revision

API Documentation at this revision

Comitter:
robert_gutknecht
Date:
Mon Nov 25 12:41:43 2013 +0000
Parent:
2:bd69e4df7955
Commit message:
test http;

Changed in this revision

HTTPServerHelloWorld.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r bd69e4df7955 -r ce7861888719 HTTPServerHelloWorld.cpp
--- 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();