Web server

Dependencies:   EthernetNetIf mbed HTTPServer

main.cpp

Committer:
nobuki
Date:
2012-06-17
Revision:
0:275cd7ae0902

File content as of revision 0:275cd7ae0902:

#include "mbed.h"
#include "EthernetNetIf.h"
#include "HTTPServer.h"

EthernetNetIf ethif( IpAddr(192,168,1,102), // IP
                     IpAddr(255,255,255,0), // Subnet mask
                     IpAddr(192,168,1,1),   // Gateway
                     IpAddr(192,168,1,1) ); // DNS
HTTPServer server;
LocalFileSystem local("local"); // Define local file mount point
DigitalOut led1(LED1);  // for alive check

int main(void)
{
    // EthernetNetIf setup
    if( ethif.setup() )
    {
        return 1;
    }

    // Mount local file path on web root path
    FSHandler::mount("/local", "/");
    // Set web root path handler
    server.addHandler<FSHandler>("/");
    
    // Set http port
    server.bind(80);

    Timer tm;
    tm.start();
    while(1)
    {
        Net::poll();
        if( 1.0 < tm.read() )
        {
            led1 = !led1;   // high->low, low->high
            tm.start();
        }
    }
}