does not show html document
Dependencies: EthernetNetIf HTTPServer mbed
Fork of HTTPServerExample by
Revision 3:fcbb86c42c3f, committed 2013-03-01
- Comitter:
- gangben
- Date:
- Fri Mar 01 19:10:53 2013 +0000
- Parent:
- 2:f8e64bf9a474
- Commit message:
- Test of a http server but it shows no html documents
Changed in this revision
HTTPServerExample.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f8e64bf9a474 -r fcbb86c42c3f HTTPServerExample.cpp --- a/HTTPServerExample.cpp Fri Jul 09 14:46:03 2010 +0000 +++ b/HTTPServerExample.cpp Fri Mar 01 19:10:53 2013 +0000 @@ -1,55 +1,48 @@ -#include "mbed.h" -#include "EthernetNetIf.h" -#include "HTTPServer.h" - -DigitalOut led1(LED1, "led1"); -DigitalOut led2(LED2, "led2"); -DigitalOut led3(LED3, "led3"); -DigitalOut led4(LED4, "led4"); - -LocalFileSystem fs("webfs"); - -EthernetNetIf eth; -HTTPServer svr; - -int main() { - Base::add_rpc_class<DigitalOut>(); - - printf("Setting up...\n"); - EthernetErr ethErr = eth.setup(); - if(ethErr) - { - printf("Error %d in setup.\n", ethErr); - return -1; - } - printf("Setup OK\n"); - - FSHandler::mount("/webfs", "/files"); //Mount /webfs path on /files web path - FSHandler::mount("/webfs", "/"); //Mount /webfs path on web root path - - svr.addHandler<SimpleHandler>("/hello"); - svr.addHandler<RPCHandler>("/rpc"); - svr.addHandler<FSHandler>("/files"); - svr.addHandler<FSHandler>("/"); //Default handler - //Example : Access to mbed.htm : http://a.b.c.d/mbed.htm or http://a.b.c.d/files/mbed.htm - - svr.bind(80); - - printf("Listening...\n"); - - Timer tm; - tm.start(); - //Listen indefinitely - while(true) - { - Net::poll(); - if(tm.read()>.5) - { - led1=!led1; //Show that we are alive - tm.start(); - } - } - - return 0; - -} +#include "mbed.h" +#include "EthernetNetIf.h" +#include "HTTPServer.h" + +DigitalOut led1(LED1, "led1"); + +LocalFileSystem fs("webfs"); + +EthernetNetIf eth( + IpAddr(192,168,1,22), + IpAddr(255,255,255,0), + IpAddr(192,168,0,1), + IpAddr(192,168,0,1) +); +HTTPServer svr; + +int main() +{ + + printf("Setting up...\n"); + EthernetErr ethErr = eth.setup(); + if(ethErr) { + printf("Error %d in setup.\n", ethErr); + return -1; + } + printf("Setup OK\n"); + + FSHandler::mount("/webfs", "/files"); //Mount /webfs path on /files web path + FSHandler::mount("/webfs", "/"); //Mount /webfs path on web root path + + svr.addHandler<FSHandler>("/files"); + svr.addHandler<FSHandler>("/"); //Default handler + //Example : Access to mbed.htm : http://a.b.c.d/mbed.htm or http://a.b.c.d/files/mbed.htm + + svr.bind(80); + + printf("Listening...\n"); + + led1 = 1; + //Listen indefinitely + while(true) { + Net::poll(); + + } + + return 0; + +}