forked from andy-thomason/python-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
23 lines (17 loc) · 669 Bytes
/
server.py
File metadata and controls
23 lines (17 loc) · 669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# code reduced from https://wiki.python.org/moin/BaseHttpServer
import time
import BaseHTTPServer
# example of a python class
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(s):
"""Respond to a GET request."""
s.send_response(200)
s.send_header("Content-type", "text/html")
s.end_headers()
s.wfile.write("<html><head><title>Title goes here.</title></head>")
s.wfile.write("<body><p>This is a test.</p>")
s.wfile.write("<p>You accessed path: %s</p>" % s.path)
s.wfile.write("</body></html>")
httpd = BaseHTTPServer.HTTPServer(("172.31.31.13", 8000), MyHandler)
httpd.serve_forever()