Chris Styles
/
HelloServerDemo
main.cpp@0:a87ea5d8da61, 2009-09-21 (annotated)
- Committer:
- chris
- Date:
- Mon Sep 21 12:08:04 2009 +0000
- Revision:
- 0:a87ea5d8da61
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chris | 0:a87ea5d8da61 | 1 | #include "mbed.h" |
chris | 0:a87ea5d8da61 | 2 | #include "HTTPServer.h" |
chris | 0:a87ea5d8da61 | 3 | #include "HTTPStaticPage.h" |
chris | 0:a87ea5d8da61 | 4 | |
chris | 0:a87ea5d8da61 | 5 | #include <string.h> |
chris | 0:a87ea5d8da61 | 6 | |
chris | 0:a87ea5d8da61 | 7 | const char content[] = "<HTML><BODY><H1>Hello World</H1></BODY></HTML>"; |
chris | 0:a87ea5d8da61 | 8 | |
chris | 0:a87ea5d8da61 | 9 | HTTPServer http; |
chris | 0:a87ea5d8da61 | 10 | |
chris | 0:a87ea5d8da61 | 11 | int main(void) { |
chris | 0:a87ea5d8da61 | 12 | http.addHandler(new HTTPStaticPage("/index.htm", content, strlen(content))); |
chris | 0:a87ea5d8da61 | 13 | http.bind(); |
chris | 0:a87ea5d8da61 | 14 | NetServer *net = NetServer::get(); |
chris | 0:a87ea5d8da61 | 15 | printf("%hhu.%hhu.%hhu.%hhu\n", (net->getIPAddr().addr)&0xFF, (net->getIPAddr().addr>>8)&0xFF, (net->getIPAddr().addr>>16)&0xFF, (net->getIPAddr().addr>>24)&0xFF); |
chris | 0:a87ea5d8da61 | 16 | while(1) { |
chris | 0:a87ea5d8da61 | 17 | http.poll(); |
chris | 0:a87ea5d8da61 | 18 | } |
chris | 0:a87ea5d8da61 | 19 | } |