-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
29 lines (23 loc) · 808 Bytes
/
Copy pathserver.py
File metadata and controls
29 lines (23 loc) · 808 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
from http.server import HTTPServer, BaseHTTPRequestHandler
import ssl
# Simple HTTP server that serves over HTTPS
# Make sure that key.pem and cert.pem are generated.
# You can use the ./generate-certs.sh script provided in this repo.
class web_server(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/':
self.path = '/encrypt-file.html'
try:
#Reading the file
file_to_open = open(self.path[1:]).read()
self.send_response(200)
except:
file_to_open = "File not found"
self.send_response(404)
self.end_headers()
self.wfile.write(bytes(file_to_open, 'utf-8'))
httpd = HTTPServer(('192.168.93.122', 4443), web_server)
httpd.socket = ssl.wrap_socket (httpd.socket,
keyfile="./key.pem",
certfile='./cert.pem', server_side=True)
httpd.serve_forever()