-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
35 lines (18 loc) · 699 Bytes
/
server.py
File metadata and controls
35 lines (18 loc) · 699 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
27
28
29
30
31
32
33
34
35
import socket
from http.server import HTTPServer
import ssl
from serverRequestsHandler import HandleRequests
SERVER_HOST_NAME = socket.gethostname()
SERVER_HOST_IP = socket.gethostbyname(SERVER_HOST_NAME)
SERVER_PORT = 4433
USE_TLS = False
def startServer():
s = HTTPServer((SERVER_HOST_IP, SERVER_PORT), HandleRequests)
if USE_TLS:
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain(certfile="./server-security/cert.pem", keyfile="./server-security/key.pem")
s.socket = context.wrap_socket(s.socket, server_side=True)
print(SERVER_HOST_IP)
s.serve_forever()
if __name__ == '__main__':
startServer()