![](/media/cache/group/DevelopConnectDevices.png.50x50_q85.png)
Demo for Mbed Connect Cloud board and an HTTP Python Server
Dependencies: C12832 mbed-http
View the tutorial for this demo here.
server/server.py@2:b91140c3c3f6, 2017-11-17 (annotated)
- Committer:
- Jenny Plunkett
- Date:
- Fri Nov 17 16:04:17 2017 -0600
- Revision:
- 2:b91140c3c3f6
- Parent:
- 0:c5b042cf8162
Fixed typo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jenny Plunkett |
0:c5b042cf8162 | 1 | from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer |
Jenny Plunkett |
0:c5b042cf8162 | 2 | import SocketServer |
Jenny Plunkett |
0:c5b042cf8162 | 3 | import socket |
Jenny Plunkett |
0:c5b042cf8162 | 4 | |
Jenny Plunkett |
0:c5b042cf8162 | 5 | class MyHandler(BaseHTTPRequestHandler): |
Jenny Plunkett |
0:c5b042cf8162 | 6 | |
Jenny Plunkett |
0:c5b042cf8162 | 7 | # HTTP REQUESTS HERE |
Jenny Plunkett |
0:c5b042cf8162 | 8 | |
Jenny Plunkett |
0:c5b042cf8162 | 9 | |
Jenny Plunkett |
0:c5b042cf8162 | 10 | |
Jenny Plunkett |
0:c5b042cf8162 | 11 | def run(): |
Jenny Plunkett |
0:c5b042cf8162 | 12 | httpd = HTTPServer(('', 8080), MyHandler) |
Jenny Plunkett |
0:c5b042cf8162 | 13 | print "HTTP server running on port 8080" |
Jenny Plunkett |
0:c5b042cf8162 | 14 | print "Your IP address is: ", socket.gethostbyname(socket.gethostname()) |
Jenny Plunkett |
0:c5b042cf8162 | 15 | httpd.serve_forever() |
Jenny Plunkett |
0:c5b042cf8162 | 16 | |
Jenny Plunkett |
0:c5b042cf8162 | 17 | if __name__ == '__main__': |
Jenny Plunkett |
0:c5b042cf8162 | 18 | run() |