Skip to content

Commit 8e0b86a

Browse files
authored
Merge pull request #74 from michalpokusa/optional-hashlib-for-websockets
Alternative import to `hashlib` and warning message about Websocket support
2 parents d1a078b + 9911f35 commit 8e0b86a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

adafruit_httpserver/response.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,19 @@
1717
import os
1818
import json
1919
from binascii import b2a_base64
20-
import hashlib
2120
from errno import EAGAIN, ECONNRESET, ETIMEDOUT, ENOTCONN
2221

22+
try:
23+
try:
24+
import hashlib
25+
except ImportError:
26+
import adafruit_hashlib as hashlib
27+
except ImportError:
28+
print(
29+
"WARNING: hashlib module not available and adafruit_hashlib not installed.",
30+
"Websocket support will not work.",
31+
)
32+
2333
from .exceptions import (
2434
BackslashInPathError,
2535
FileNotExistsError,

0 commit comments

Comments
 (0)