-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestServer.py
More file actions
43 lines (38 loc) · 1.39 KB
/
testServer.py
File metadata and controls
43 lines (38 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from http.server import BaseHTTPRequestHandler, HTTPServer
import socket
import time
# Change these
# hostName = socket.gethostbyname(socket.gethostname())
# hostName = "" # Private IP Address
serverPort = 8080
class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write(bytes("""
<html>
<head>
<title>Hello</title>
</head>
<body>
<h1>Hello World!</h1>
<div>
<img src="https://c.tenor.com/mGgWY8RkgYMAAAAC/hello-world.gif" alt = "Hello World Gif">
</div>
<br>
<div>
<img src = "https://upload.wikimedia.org/wikipedia/commons/c/cc/Digital_rain_animation_medium_letters_shine.gif" alt = "MRain Gif">
</div>
</body>
</html>""", "utf-8"))
# self.wfile.write(bytes("<p>Request: %s</p>" % self.path, "utf-8"))
if __name__ == "__main__":
webServer = HTTPServer((hostName, serverPort), MyServer)
print("Server started http://%s:%s" % (hostName, serverPort))
try:
webServer.serve_forever()
except KeyboardInterrupt:
pass
webServer.server_close()
print("Server stopped.")