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: EthernetInterface mbed-rpc mbed-rtos mbed
Fork of HTTP-Server by
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 #include "mbed_rpc.h" 00004 #include "RPCCommand.h" 00005 #include "HTTPServer.h" 00006 #include "Formatter.h" 00007 #include "RequestHandler.h" 00008 #include "RPCType.h" 00009 00010 #define SERVER_PORT 80 00011 00012 HTTPServer create_simple_server() 00013 { 00014 HTTPServer srv; 00015 srv.add_request_handler("DELETE", new DeleteRequestHandler()); 00016 srv.add_request_handler("GET", new GetRequestHandler()); 00017 srv.add_request_handler("PUT", new PutRequestHandler()); 00018 return srv; 00019 } 00020 00021 HTTPServer create_interactive_server() 00022 { 00023 HTTPServer srv(new InteractiveHTMLFormatter()); 00024 srv.add_request_handler("GET", new ComplexRequestHandler()); 00025 return srv; 00026 } 00027 00028 int main(void) 00029 { 00030 RPCType::instance().register_types(); 00031 00032 EthernetInterface eth; 00033 if(eth.init()) 00034 { 00035 printf("Error while initializing the ethernet interface.\n"); 00036 return -1; 00037 } 00038 if(eth.connect()) 00039 { 00040 printf("Error while starting the ethernet interface.\n"); 00041 return -1; 00042 } 00043 00044 printf("IP Address is %s\n", eth.getIPAddress()); 00045 00046 HTTPServer srv = create_interactive_server(); 00047 00048 if(!srv.init(SERVER_PORT)) 00049 { 00050 eth.disconnect(); 00051 return -1; 00052 } 00053 00054 srv.run(); 00055 00056 return 0; 00057 } 00058
Generated on Thu Jul 14 2022 01:35:56 by
1.7.2
