This is a simplest HTTP server made of libMiMic. It will echo back a request path.
Dependencies: libMiMic mbed-rtos mbed NySDFileSystem
最も簡単なhttpdです。 クライアントから送信されてきたURLをHtmlにして返します。
ModUrlモジュールのサンプルでもあります。
This program is simple httpserver.
This is tutorial for ModUrl module.
main.cpp
- Committer:
- nyatla
- Date:
- 2013-04-06
- Revision:
- 2:28fd59d6be76
- Parent:
- 0:ec1e45489427
- Child:
- 5:00daa91538bc
File content as of revision 2:28fd59d6be76:
#include "mimic.h" /** * MiMic RemoteMCU httpd.<br/> * <p>Service list</p> * <pre> * /rom/ - romfs * /setup/ - MiMic configulation REST API. * /local/ - mbed LocalFileSystem * /mvm/ - MiMicVM REST API * </pre> */ class MiMicRemoteMcu:public MiMic::Httpd { private: ModUrl modurl; //basic URL parser public: MiMicRemoteMcu():Httpd(80) { } virtual void onRequest(HttpdConnection& i_connection) { char url[32]; int method; //call ModUrl module. if(this->modurl.execute(i_connection,url,32,&method)){ //send 200 OK and requested URL i_connection.sendHeader(200,"text/html",NULL); i_connection.sendBodyF("<html><body>Your Request path is %s.</body></html>",url); return; } return; } }; int main() { NetConfig cfg; //create network configulation Net net(cfg); //create a net instance. MiMicRemoteMcu httpd; //create a httpd instance. httpd.loop(); //start httpd loop. return 0; }