does not show html document
Dependencies: EthernetNetIf HTTPServer mbed
Fork of HTTPServerExample by
HTTPServerExample.cpp@3:fcbb86c42c3f, 2013-03-01 (annotated)
- Committer:
- gangben
- Date:
- Fri Mar 01 19:10:53 2013 +0000
- Revision:
- 3:fcbb86c42c3f
- Parent:
- 1:114e347434c1
Test of a http server but it shows no html documents
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gangben | 3:fcbb86c42c3f | 1 | #include "mbed.h" |
gangben | 3:fcbb86c42c3f | 2 | #include "EthernetNetIf.h" |
gangben | 3:fcbb86c42c3f | 3 | #include "HTTPServer.h" |
gangben | 3:fcbb86c42c3f | 4 | |
gangben | 3:fcbb86c42c3f | 5 | DigitalOut led1(LED1, "led1"); |
gangben | 3:fcbb86c42c3f | 6 | |
gangben | 3:fcbb86c42c3f | 7 | LocalFileSystem fs("webfs"); |
gangben | 3:fcbb86c42c3f | 8 | |
gangben | 3:fcbb86c42c3f | 9 | EthernetNetIf eth( |
gangben | 3:fcbb86c42c3f | 10 | IpAddr(192,168,1,22), |
gangben | 3:fcbb86c42c3f | 11 | IpAddr(255,255,255,0), |
gangben | 3:fcbb86c42c3f | 12 | IpAddr(192,168,0,1), |
gangben | 3:fcbb86c42c3f | 13 | IpAddr(192,168,0,1) |
gangben | 3:fcbb86c42c3f | 14 | ); |
gangben | 3:fcbb86c42c3f | 15 | HTTPServer svr; |
gangben | 3:fcbb86c42c3f | 16 | |
gangben | 3:fcbb86c42c3f | 17 | int main() |
gangben | 3:fcbb86c42c3f | 18 | { |
gangben | 3:fcbb86c42c3f | 19 | |
gangben | 3:fcbb86c42c3f | 20 | printf("Setting up...\n"); |
gangben | 3:fcbb86c42c3f | 21 | EthernetErr ethErr = eth.setup(); |
gangben | 3:fcbb86c42c3f | 22 | if(ethErr) { |
gangben | 3:fcbb86c42c3f | 23 | printf("Error %d in setup.\n", ethErr); |
gangben | 3:fcbb86c42c3f | 24 | return -1; |
gangben | 3:fcbb86c42c3f | 25 | } |
gangben | 3:fcbb86c42c3f | 26 | printf("Setup OK\n"); |
gangben | 3:fcbb86c42c3f | 27 | |
gangben | 3:fcbb86c42c3f | 28 | FSHandler::mount("/webfs", "/files"); //Mount /webfs path on /files web path |
gangben | 3:fcbb86c42c3f | 29 | FSHandler::mount("/webfs", "/"); //Mount /webfs path on web root path |
gangben | 3:fcbb86c42c3f | 30 | |
gangben | 3:fcbb86c42c3f | 31 | svr.addHandler<FSHandler>("/files"); |
gangben | 3:fcbb86c42c3f | 32 | svr.addHandler<FSHandler>("/"); //Default handler |
gangben | 3:fcbb86c42c3f | 33 | //Example : Access to mbed.htm : http://a.b.c.d/mbed.htm or http://a.b.c.d/files/mbed.htm |
gangben | 3:fcbb86c42c3f | 34 | |
gangben | 3:fcbb86c42c3f | 35 | svr.bind(80); |
gangben | 3:fcbb86c42c3f | 36 | |
gangben | 3:fcbb86c42c3f | 37 | printf("Listening...\n"); |
gangben | 3:fcbb86c42c3f | 38 | |
gangben | 3:fcbb86c42c3f | 39 | led1 = 1; |
gangben | 3:fcbb86c42c3f | 40 | //Listen indefinitely |
gangben | 3:fcbb86c42c3f | 41 | while(true) { |
gangben | 3:fcbb86c42c3f | 42 | Net::poll(); |
gangben | 3:fcbb86c42c3f | 43 | |
gangben | 3:fcbb86c42c3f | 44 | } |
gangben | 3:fcbb86c42c3f | 45 | |
gangben | 3:fcbb86c42c3f | 46 | return 0; |
gangben | 3:fcbb86c42c3f | 47 | |
gangben | 3:fcbb86c42c3f | 48 | } |