-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
26 lines (20 loc) · 682 Bytes
/
main.py
File metadata and controls
26 lines (20 loc) · 682 Bytes
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
from http.server import HTTPServer, BaseHTTPRequestHandler
class Server(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
# get the page
path = self.path
if path == '/':
with open('home.html', 'rb') as page:
self.wfile.write(page.read())
elif path == '/about':
with open('about.html', 'rb') as page:
self.wfile.write(page.read())
try:
server = HTTPServer(('localhost', 8080), Server)
server.serve_forever()
except:
pass
server.server_close()