I’m having trouble using SSL with the Web Server DAT. It works fine with http, but when I try to switch over to https, I get weird problems. For instance, if I connect with Firefox, I can load an HTML page just fine but if I try to refresh that same page, I get a PR_END_OF_FILE_ERROR.
Since it works fine on http, I’m tempted to think that my code is correct, but maybe I’m overlooking something. This is on macOS with TouchDesigner v2021.12380.
Here’s the code that handles HTTP requests:
def onHTTPRequest(webServerDAT, request, response):
utf8 = [
"application/javascript",
"application/json",
"text/css",
"text/javascript"
]
# Path
path = "www" + request["uri"]
if (request["uri"].endswith('/')): path += "index.html"
# MIME Type
type = mimetypes.guess_type(chemin)[0] # tuple: (type, encodage)
if type in utf8: type += "; charset=utf-8"
# Response
try:
reader = open(path, "r")
data = reader.read()
reader.close()
response['statusCode'] = 200
response['statusReason'] = 'OK'
response['content-type'] = type
response['data'] = data
except FileNotFoundError:
response['statusCode'] = 404
response['statusReason'] = 'Not Found'
return response
Ideas?