forked from digitalocean/sample-python
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
Latest commit
19 lines (14 loc) · 470 Bytes
/
Copy pathserver.py
File metadata and controls
19 lines (14 loc) · 470 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
importos
importhttp.server
importsocketserver
fromhttpimportHTTPStatus
classHandler(http.server.SimpleHTTPRequestHandler):
defdo_GET(self):
self.send_response(HTTPStatus.OK)
self.end_headers()
msg='Hello! you 111 requested %s'% (self.path)
self.wfile.write(msg.encode())
port=int(os.getenv('PORT', 80))
print('Listening on port %s'% (port))
httpd=socketserver.TCPServer(('', port), Handler)
httpd.serve_forever()