Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetNetIf HTTPServer mbed
Fork of HTTPServerExample by
HTTPServerExample.cpp
00001 #include "mbed.h" 00002 #include "EthernetNetIf.h" 00003 #include "HTTPServer.h" 00004 00005 DigitalOut led1(LED1, "led1"); 00006 00007 LocalFileSystem fs("webfs"); 00008 00009 EthernetNetIf eth( 00010 IpAddr(192,168,1,22), 00011 IpAddr(255,255,255,0), 00012 IpAddr(192,168,0,1), 00013 IpAddr(192,168,0,1) 00014 ); 00015 HTTPServer svr; 00016 00017 int main() 00018 { 00019 00020 printf("Setting up...\n"); 00021 EthernetErr ethErr = eth.setup(); 00022 if(ethErr) { 00023 printf("Error %d in setup.\n", ethErr); 00024 return -1; 00025 } 00026 printf("Setup OK\n"); 00027 00028 FSHandler::mount("/webfs", "/files"); //Mount /webfs path on /files web path 00029 FSHandler::mount("/webfs", "/"); //Mount /webfs path on web root path 00030 00031 svr.addHandler<FSHandler>("/files"); 00032 svr.addHandler<FSHandler>("/"); //Default handler 00033 //Example : Access to mbed.htm : http://a.b.c.d/mbed.htm or http://a.b.c.d/files/mbed.htm 00034 00035 svr.bind(80); 00036 00037 printf("Listening...\n"); 00038 00039 led1 = 1; 00040 //Listen indefinitely 00041 while(true) { 00042 Net::poll(); 00043 00044 } 00045 00046 return 0; 00047 00048 }
Generated on Wed Jul 13 2022 10:07:49 by
1.7.2
