Skip to content

Commit e7ea853

Browse files
author
Joel Collins
committed
Add werkzeug debugger
1 parent e815422 commit e7ea853

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

labthings/server/wsgi.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import sys
55
import os
6+
from werkzeug.debug import DebuggedApplication
67

78

89
class Server:
@@ -14,11 +15,17 @@ def run(self, host="0.0.0.0", port=5000, log=None, debug=False):
1415
port = int(port)
1516
host = str(host)
1617

18+
# Unmodified version of app
19+
app_to_run = self.app
20+
1721
# Handle logging
1822
if not log:
1923
log = logging.getLogger()
24+
25+
# Handle debug mode
2026
if debug:
2127
log.setLevel(logging.DEBUG)
28+
app_to_run = DebuggedApplication(self.app)
2229

2330
friendlyhost = "localhost" if host == "0.0.0.0" else host
2431
logging.info("Starting LabThings WSGI Server")
@@ -27,7 +34,7 @@ def run(self, host="0.0.0.0", port=5000, log=None, debug=False):
2734

2835
# Create WSGIServer
2936
wsgi_server = pywsgi.WSGIServer(
30-
(host, port), self.app, handler_class=WebSocketHandler, log=log
37+
(host, port), app_to_run, handler_class=WebSocketHandler, log=log
3138
)
3239

3340
# Serve

0 commit comments

Comments
 (0)