crosswords/server/main.py

23 lines
535 B
Python
Raw Normal View History

2021-06-17 16:12:16 +02:00
import ssl
import logging
2021-06-17 16:02:50 +02:00
from . import json_websockets
from . import crossword_connection
2021-06-17 16:12:16 +02:00
try:
2021-06-17 16:14:45 +02:00
cert_file = "./server/fullchain.pem"
key_file = "./server/privkey.pem"
2021-06-17 16:12:16 +02:00
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ssl_context.load_cert_chain(cert_file, keyfile=key_file)
except Exception as e:
2021-06-17 16:14:45 +02:00
logging.error("no ssl context available: %s", str(e))
2021-06-17 16:12:16 +02:00
ssl_context = None
2021-06-17 16:02:50 +02:00
server = json_websockets.JsonWebsocketServer(
2021-06-17 16:12:16 +02:00
crossword_connection.CrosswordConnection, ssl_context=ssl_context
2021-06-17 16:02:50 +02:00
)
2021-06-17 16:12:16 +02:00
server.run()