From 80e415685156bfc0e11e2128b2334ffcf0667d0b Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 7 Aug 2020 16:01:14 +0200 Subject: [PATCH 1/5] tls example with test.mosquitto.org certs --- .gitignore | 3 +- example/simple-mqtt-web-interface-tls/app.py | 88 +++++++++++ .../environment.yml | 44 ++++++ .../templates/index.html | 0 .../{ => simple-mqtt-web-interface}/app.py | 0 .../environment.yml | 0 .../requirements.txt | 0 .../templates/index.html | 145 ++++++++++++++++++ 8 files changed, 279 insertions(+), 1 deletion(-) create mode 100644 example/simple-mqtt-web-interface-tls/app.py create mode 100644 example/simple-mqtt-web-interface-tls/environment.yml rename example/{ => simple-mqtt-web-interface-tls}/templates/index.html (100%) rename example/{ => simple-mqtt-web-interface}/app.py (100%) rename example/{ => simple-mqtt-web-interface}/environment.yml (100%) rename example/{ => simple-mqtt-web-interface}/requirements.txt (100%) create mode 100644 example/simple-mqtt-web-interface/templates/index.html diff --git a/.gitignore b/.gitignore index 3180314..b45db67 100644 --- a/.gitignore +++ b/.gitignore @@ -90,6 +90,7 @@ ENV/ *.sublime* doc/_build/* *.crt +client.key .mypy_cache/* venv_*/ @@ -97,4 +98,4 @@ Pipfile.log # IDE configuration .idea/ -.vscode/ \ No newline at end of file +.vscode/ diff --git a/example/simple-mqtt-web-interface-tls/app.py b/example/simple-mqtt-web-interface-tls/app.py new file mode 100644 index 0000000..7c3b773 --- /dev/null +++ b/example/simple-mqtt-web-interface-tls/app.py @@ -0,0 +1,88 @@ +""" + +A small Test application to show how to use Flask-MQTT. + +""" +import logging + +import eventlet +import json +from flask import Flask, render_template +from flask_mqtt import Mqtt +from flask_socketio import SocketIO +from flask_bootstrap import Bootstrap +from flask_mqtt import ssl + + +eventlet.monkey_patch() + +app = Flask(__name__) +app.config['SECRET'] = 'my secret key' +app.config['TEMPLATES_AUTO_RELOAD'] = True + +app.config['MQTT_CLIENT_ID'] = 'flask_mqtt' +app.config['MQTT_CLEAN_SESSION'] = True +app.config['MQTT_KEEPALIVE'] = 5 +app.config['MQTT_LAST_WILL_TOPIC'] = 'home/lastwill' +app.config['MQTT_LAST_WILL_MESSAGE'] = 'bye' +app.config['MQTT_LAST_WILL_QOS'] = 2 + +# Parameters for SSL enabled +app.config['MQTT_TLS_ENABLED'] = True +app.config['MQTT_BROKER_URL'] = 'test.mosquitto.org' +app.config['MQTT_BROKER_PORT'] = 8884 +app.config['MQTT_TLS_INSECURE'] = False +app.config['MQTT_TLS_CA_CERTS'] = 'mosquitto.org.crt' +app.config['MQTT_TLS_CERTFILE'] = 'client.crt' +app.config['MQTT_TLS_KEYFILE'] = 'client.key' +app.config['MQTT_TLS_VERSION'] = ssl.PROTOCOL_TLSv1_2 +app.config['MQTT_TLS_CERT_REQS'] = True +# if broker requires cert + user/pass then set this here +#app.config['MQTT_USERNAME'] = '' +#app.config['MQTT_PASSWORD'] = '' + +mqtt = Mqtt(app) +socketio = SocketIO(app) +bootstrap = Bootstrap(app) + + +@app.route('/') +def index(): + return render_template('index.html') + + +@socketio.on('publish') +def handle_publish(json_str): + data = json.loads(json_str) + mqtt.publish(data['topic'], data['message'], data['qos']) + + +@socketio.on('subscribe') +def handle_subscribe(json_str): + data = json.loads(json_str) + mqtt.subscribe(data['topic'], data['qos']) + + +@socketio.on('unsubscribe_all') +def handle_unsubscribe_all(): + mqtt.unsubscribe_all() + + +@mqtt.on_message() +def handle_mqtt_message(client, userdata, message): + data = dict( + topic=message.topic, + payload=message.payload.decode(), + qos=message.qos, + ) + socketio.emit('mqtt_message', data=data) + + +@mqtt.on_log() +def handle_logging(client, userdata, level, buf): + # print(level, buf) + pass + + +if __name__ == '__main__': + socketio.run(app, host='0.0.0.0', port=5000, use_reloader=False, debug=True) diff --git a/example/simple-mqtt-web-interface-tls/environment.yml b/example/simple-mqtt-web-interface-tls/environment.yml new file mode 100644 index 0000000..3a670b1 --- /dev/null +++ b/example/simple-mqtt-web-interface-tls/environment.yml @@ -0,0 +1,44 @@ +name: venv +channels: + - conda-forge + - pytorch + - defaults +dependencies: + - ca-certificates=2019.11.28=hecc5488_0 + - certifi=2019.11.28=py38_0 + - click=7.0=py_0 + - flask=1.1.1=py_1 + - flask-socketio=3.3.2=py_0 + - itsdangerous=1.1.0=py_0 + - jinja2=2.11.1=py_0 + - libcxx=9.0.1=1 + - libffi=3.2.1=h6de7cb9_1006 + - markupsafe=1.1.1=py38h0b31af3_0 + - ncurses=6.1=h0a44026_1002 + - openssl=1.1.1d=h0b31af3_0 + - pip=20.0.2=py_2 + - python=3.8.1=hf2284b6_2 + - readline=8.0=hcfe32e1_0 + - setuptools=45.1.0=py38_0 + - six=1.14.0=py38_0 + - sqlite=3.30.1=h93121df_0 + - tk=8.6.10=hbbe82c9_0 + - werkzeug=1.0.0=py_0 + - wheel=0.34.2=py_1 + - xz=5.2.4=h1de35cc_1001 + - zlib=1.2.11=h0b31af3_1006 + - pip: + - dnspython==1.16.0 + - dominate==2.4.0 + - eventlet==0.25.1 + - flask-bootstrap==3.3.7.1 + - flask-mqtt==1.0.5 + - greenlet==0.4.15 + - monotonic==1.5 + - paho-mqtt==1.5.0 + - python-engineio==3.11.2 + - python-socketio==4.4.0 + - typing==3.7.4.1 + - visitor==0.1.3 +prefix: venv + diff --git a/example/templates/index.html b/example/simple-mqtt-web-interface-tls/templates/index.html similarity index 100% rename from example/templates/index.html rename to example/simple-mqtt-web-interface-tls/templates/index.html diff --git a/example/app.py b/example/simple-mqtt-web-interface/app.py similarity index 100% rename from example/app.py rename to example/simple-mqtt-web-interface/app.py diff --git a/example/environment.yml b/example/simple-mqtt-web-interface/environment.yml similarity index 100% rename from example/environment.yml rename to example/simple-mqtt-web-interface/environment.yml diff --git a/example/requirements.txt b/example/simple-mqtt-web-interface/requirements.txt similarity index 100% rename from example/requirements.txt rename to example/simple-mqtt-web-interface/requirements.txt diff --git a/example/simple-mqtt-web-interface/templates/index.html b/example/simple-mqtt-web-interface/templates/index.html new file mode 100644 index 0000000..a51921e --- /dev/null +++ b/example/simple-mqtt-web-interface/templates/index.html @@ -0,0 +1,145 @@ +{% extends "bootstrap/base.html" %} +{% block title %}Flask-MQTT example{% endblock %} + +{% block styles %} +{{ super() }} +{% endblock %} + +{% block scripts %} +{{ super() }} + + +{% endblock %} + +{% block content %} +
+
+
+

Flask-MQTT Example

+
+
+
+
+
+
+

Publish MQTT Message

+
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+

Subscribe MQTT Messages

+
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + +
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+{% endblock %} From 7edd128db9e90847bfd6e210c005dae11d4c4833 Mon Sep 17 00:00:00 2001 From: Andreas Loeffler Date: Thu, 12 Jan 2023 20:28:29 +0100 Subject: [PATCH 2/5] adding the requirements file from the previous example. remove whitespace at end of line --- .../requirements.txt | 21 +++++++++++++++++++ .../templates/index.html | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 example/simple-mqtt-web-interface-tls/requirements.txt diff --git a/example/simple-mqtt-web-interface-tls/requirements.txt b/example/simple-mqtt-web-interface-tls/requirements.txt new file mode 100644 index 0000000..734e7f8 --- /dev/null +++ b/example/simple-mqtt-web-interface-tls/requirements.txt @@ -0,0 +1,21 @@ +certifi==2022.12.7 +Click==7.0 +dnspython==1.16.0 +dominate==2.4.0 +eventlet==0.25.1 +Flask==1.1.1 +Flask-Bootstrap==3.3.7.1 +Flask-MQTT==1.0.5 +Flask-SocketIO==3.3.2 +greenlet==0.4.15 +itsdangerous==1.1.0 +Jinja2==2.11.1 +MarkupSafe==1.1.1 +monotonic==1.5 +paho-mqtt==1.5.0 +python-engineio==3.11.2 +python-socketio==4.4.0 +six==1.14.0 +typing==3.7.4.1 +visitor==0.1.3 +Werkzeug==1.0.0 diff --git a/example/simple-mqtt-web-interface/templates/index.html b/example/simple-mqtt-web-interface/templates/index.html index a51921e..1bcc328 100644 --- a/example/simple-mqtt-web-interface/templates/index.html +++ b/example/simple-mqtt-web-interface/templates/index.html @@ -84,7 +84,7 @@

Publish MQTT Message

- +
@@ -120,7 +120,7 @@

Subscribe MQTT Messages

-
+
From f725ecd7d208fdd2ae688695bda35d24563c5333 Mon Sep 17 00:00:00 2001 From: Andreas Loeffler Date: Fri, 13 Jan 2023 17:39:20 +0100 Subject: [PATCH 3/5] rearrange the sample apps to share common environment and template --- .../environment.yml | 0 .../requirements.txt | 0 ...pp.py => simple-mqtt-web-interface-tls.py} | 0 .../templates/index.html | 145 ------------------ .../app.py => simple-mqtt-web-interface.py} | 0 .../simple-mqtt-web-interface/environment.yml | 44 ------ .../requirements.txt | 21 --- .../templates/index.html | 0 8 files changed, 210 deletions(-) rename example/{simple-mqtt-web-interface-tls => }/environment.yml (100%) rename example/{simple-mqtt-web-interface-tls => }/requirements.txt (100%) rename example/{simple-mqtt-web-interface-tls/app.py => simple-mqtt-web-interface-tls.py} (100%) delete mode 100644 example/simple-mqtt-web-interface-tls/templates/index.html rename example/{simple-mqtt-web-interface/app.py => simple-mqtt-web-interface.py} (100%) delete mode 100644 example/simple-mqtt-web-interface/environment.yml delete mode 100644 example/simple-mqtt-web-interface/requirements.txt rename example/{simple-mqtt-web-interface => }/templates/index.html (100%) diff --git a/example/simple-mqtt-web-interface-tls/environment.yml b/example/environment.yml similarity index 100% rename from example/simple-mqtt-web-interface-tls/environment.yml rename to example/environment.yml diff --git a/example/simple-mqtt-web-interface-tls/requirements.txt b/example/requirements.txt similarity index 100% rename from example/simple-mqtt-web-interface-tls/requirements.txt rename to example/requirements.txt diff --git a/example/simple-mqtt-web-interface-tls/app.py b/example/simple-mqtt-web-interface-tls.py similarity index 100% rename from example/simple-mqtt-web-interface-tls/app.py rename to example/simple-mqtt-web-interface-tls.py diff --git a/example/simple-mqtt-web-interface-tls/templates/index.html b/example/simple-mqtt-web-interface-tls/templates/index.html deleted file mode 100644 index a51921e..0000000 --- a/example/simple-mqtt-web-interface-tls/templates/index.html +++ /dev/null @@ -1,145 +0,0 @@ -{% extends "bootstrap/base.html" %} -{% block title %}Flask-MQTT example{% endblock %} - -{% block styles %} -{{ super() }} -{% endblock %} - -{% block scripts %} -{{ super() }} - - -{% endblock %} - -{% block content %} -
-
-
-

Flask-MQTT Example

-
-
-
-
-
-
-

Publish MQTT Message

-
-
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-

Subscribe MQTT Messages

-
-
-
-
-
-
- -
- -
-
-
- -
- -
-
-
-
- - -
-
-
- -
- -
-
-
-
-
-
-
-
-
-
-{% endblock %} diff --git a/example/simple-mqtt-web-interface/app.py b/example/simple-mqtt-web-interface.py similarity index 100% rename from example/simple-mqtt-web-interface/app.py rename to example/simple-mqtt-web-interface.py diff --git a/example/simple-mqtt-web-interface/environment.yml b/example/simple-mqtt-web-interface/environment.yml deleted file mode 100644 index 694823d..0000000 --- a/example/simple-mqtt-web-interface/environment.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: /Users/stefan/Documents/python/projects/Flask-MQTT/example/venv -channels: - - conda-forge - - pytorch - - defaults -dependencies: - - ca-certificates=2019.11.28=hecc5488_0 - - certifi=2019.11.28=py38_0 - - click=7.0=py_0 - - flask=1.1.1=py_1 - - flask-socketio=3.3.2=py_0 - - itsdangerous=1.1.0=py_0 - - jinja2=2.11.1=py_0 - - libcxx=9.0.1=1 - - libffi=3.2.1=h6de7cb9_1006 - - markupsafe=1.1.1=py38h0b31af3_0 - - ncurses=6.1=h0a44026_1002 - - openssl=1.1.1d=h0b31af3_0 - - pip=20.0.2=py_2 - - python=3.8.1=hf2284b6_2 - - readline=8.0=hcfe32e1_0 - - setuptools=45.1.0=py38_0 - - six=1.14.0=py38_0 - - sqlite=3.30.1=h93121df_0 - - tk=8.6.10=hbbe82c9_0 - - werkzeug=1.0.0=py_0 - - wheel=0.34.2=py_1 - - xz=5.2.4=h1de35cc_1001 - - zlib=1.2.11=h0b31af3_1006 - - pip: - - dnspython==1.16.0 - - dominate==2.4.0 - - eventlet==0.25.1 - - flask-bootstrap==3.3.7.1 - - flask-mqtt==1.0.5 - - greenlet==0.4.15 - - monotonic==1.5 - - paho-mqtt==1.5.0 - - python-engineio==3.11.2 - - python-socketio==4.4.0 - - typing==3.7.4.1 - - visitor==0.1.3 -prefix: /Users/stefan/Documents/python/projects/Flask-MQTT/example/venv - diff --git a/example/simple-mqtt-web-interface/requirements.txt b/example/simple-mqtt-web-interface/requirements.txt deleted file mode 100644 index 734e7f8..0000000 --- a/example/simple-mqtt-web-interface/requirements.txt +++ /dev/null @@ -1,21 +0,0 @@ -certifi==2022.12.7 -Click==7.0 -dnspython==1.16.0 -dominate==2.4.0 -eventlet==0.25.1 -Flask==1.1.1 -Flask-Bootstrap==3.3.7.1 -Flask-MQTT==1.0.5 -Flask-SocketIO==3.3.2 -greenlet==0.4.15 -itsdangerous==1.1.0 -Jinja2==2.11.1 -MarkupSafe==1.1.1 -monotonic==1.5 -paho-mqtt==1.5.0 -python-engineio==3.11.2 -python-socketio==4.4.0 -six==1.14.0 -typing==3.7.4.1 -visitor==0.1.3 -Werkzeug==1.0.0 diff --git a/example/simple-mqtt-web-interface/templates/index.html b/example/templates/index.html similarity index 100% rename from example/simple-mqtt-web-interface/templates/index.html rename to example/templates/index.html From 1d7c4a4ff96ff4ae4c49259eb0a18fd56e176ac4 Mon Sep 17 00:00:00 2001 From: Andreas Loeffler Date: Fri, 13 Jan 2023 17:58:50 +0100 Subject: [PATCH 4/5] bump some modules to newer versions --- example/requirements.txt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/example/requirements.txt b/example/requirements.txt index 734e7f8..35bcb72 100644 --- a/example/requirements.txt +++ b/example/requirements.txt @@ -1,21 +1,22 @@ +bidict==0.22.1 certifi==2022.12.7 Click==7.0 dnspython==1.16.0 dominate==2.4.0 -eventlet==0.25.1 -Flask==1.1.1 +eventlet==0.33.2 +Flask==1.1.4 Flask-Bootstrap==3.3.7.1 -Flask-MQTT==1.0.5 -Flask-SocketIO==3.3.2 -greenlet==0.4.15 +Flask-MQTT==1.1.1 +Flask-SocketIO==5.3.2 +greenlet==2.0.1 itsdangerous==1.1.0 -Jinja2==2.11.1 +Jinja2==2.11.3 MarkupSafe==1.1.1 monotonic==1.5 paho-mqtt==1.5.0 -python-engineio==3.11.2 -python-socketio==4.4.0 +python-engineio==4.3.4 +python-socketio==5.7.2 six==1.14.0 typing==3.7.4.1 visitor==0.1.3 -Werkzeug==1.0.0 +Werkzeug==1.0.1 From 56365481db90134296008c8983febf53bd2b57b5 Mon Sep 17 00:00:00 2001 From: Andreas Loeffler Date: Sun, 1 Oct 2023 19:05:25 +0200 Subject: [PATCH 5/5] update PR, revert much of the previous stuff and only add another commented section to the existing example --- README.md | 16 ++++ .../{simple-mqtt-web-interface.py => app.py} | 14 +++ example/simple-mqtt-web-interface-tls.py | 88 ------------------- 3 files changed, 30 insertions(+), 88 deletions(-) rename example/{simple-mqtt-web-interface.py => app.py} (78%) delete mode 100644 example/simple-mqtt-web-interface-tls.py diff --git a/README.md b/README.md index 68f64c4..8d44bbf 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,9 @@ mqtt3 = Mqtt(app, config_prefix="MQTT3") ``` ### Small publish/subscribe MQTT client +Note: if you want to enable ssl transport layer on the mqtt communication +take a look at the commented sections in the example file. +You may need to add or replace some of the MQTT_TLS options and adjust to your needs. ```python """ @@ -160,6 +163,8 @@ from flask import Flask, render_template from flask_mqtt import Mqtt from flask_socketio import SocketIO from flask_bootstrap import Bootstrap +# if SSL enabled +# from flask_mqtt import ssl eventlet.monkey_patch() @@ -180,6 +185,17 @@ app.config['MQTT_CLEAN_SESSION'] = True # app.config['MQTT_TLS_INSECURE'] = True # app.config['MQTT_TLS_CA_CERTS'] = 'ca.crt' +# Parmeters for SSL with client certificate +# app.config['MQTT_TLS_ENABLED'] = True +# app.config['MQTT_BROKER_URL'] = 'test.mosquitto.org' +# app.config['MQTT_BROKER_PORT'] = 8884 +# app.config['MQTT_TLS_INSECURE'] = False +# app.config['MQTT_TLS_CA_CERTS'] = 'mosquitto.org.crt' +# app.config['MQTT_TLS_CERTFILE'] = 'client.crt' +# app.config['MQTT_TLS_KEYFILE'] = 'client.key' +# app.config['MQTT_TLS_VERSION'] = ssl.PROTOCOL_TLSv1_2 +# app.config['MQTT_TLS_CERT_REQS'] = True + mqtt = Mqtt(app) socketio = SocketIO(app) bootstrap = Bootstrap(app) diff --git a/example/simple-mqtt-web-interface.py b/example/app.py similarity index 78% rename from example/simple-mqtt-web-interface.py rename to example/app.py index 392ea86..1f8eb05 100644 --- a/example/simple-mqtt-web-interface.py +++ b/example/app.py @@ -11,6 +11,8 @@ from flask_mqtt import Mqtt from flask_socketio import SocketIO from flask_bootstrap import Bootstrap +# if SSL enabled +# from flask_mqtt import ssl eventlet.monkey_patch() @@ -35,6 +37,18 @@ # app.config['MQTT_TLS_INSECURE'] = True # app.config['MQTT_TLS_CA_CERTS'] = 'ca.crt' +# Parmeters for SSL with client certificate +# app.config['MQTT_TLS_ENABLED'] = True +# app.config['MQTT_BROKER_URL'] = 'test.mosquitto.org' +# app.config['MQTT_BROKER_PORT'] = 8884 +# app.config['MQTT_TLS_INSECURE'] = False +# app.config['MQTT_TLS_CA_CERTS'] = 'mosquitto.org.crt' +# app.config['MQTT_TLS_CERTFILE'] = 'client.crt' +# app.config['MQTT_TLS_KEYFILE'] = 'client.key' +# app.config['MQTT_TLS_VERSION'] = ssl.PROTOCOL_TLSv1_2 +# app.config['MQTT_TLS_CERT_REQS'] = True + + mqtt = Mqtt(app) socketio = SocketIO(app) bootstrap = Bootstrap(app) diff --git a/example/simple-mqtt-web-interface-tls.py b/example/simple-mqtt-web-interface-tls.py deleted file mode 100644 index 7c3b773..0000000 --- a/example/simple-mqtt-web-interface-tls.py +++ /dev/null @@ -1,88 +0,0 @@ -""" - -A small Test application to show how to use Flask-MQTT. - -""" -import logging - -import eventlet -import json -from flask import Flask, render_template -from flask_mqtt import Mqtt -from flask_socketio import SocketIO -from flask_bootstrap import Bootstrap -from flask_mqtt import ssl - - -eventlet.monkey_patch() - -app = Flask(__name__) -app.config['SECRET'] = 'my secret key' -app.config['TEMPLATES_AUTO_RELOAD'] = True - -app.config['MQTT_CLIENT_ID'] = 'flask_mqtt' -app.config['MQTT_CLEAN_SESSION'] = True -app.config['MQTT_KEEPALIVE'] = 5 -app.config['MQTT_LAST_WILL_TOPIC'] = 'home/lastwill' -app.config['MQTT_LAST_WILL_MESSAGE'] = 'bye' -app.config['MQTT_LAST_WILL_QOS'] = 2 - -# Parameters for SSL enabled -app.config['MQTT_TLS_ENABLED'] = True -app.config['MQTT_BROKER_URL'] = 'test.mosquitto.org' -app.config['MQTT_BROKER_PORT'] = 8884 -app.config['MQTT_TLS_INSECURE'] = False -app.config['MQTT_TLS_CA_CERTS'] = 'mosquitto.org.crt' -app.config['MQTT_TLS_CERTFILE'] = 'client.crt' -app.config['MQTT_TLS_KEYFILE'] = 'client.key' -app.config['MQTT_TLS_VERSION'] = ssl.PROTOCOL_TLSv1_2 -app.config['MQTT_TLS_CERT_REQS'] = True -# if broker requires cert + user/pass then set this here -#app.config['MQTT_USERNAME'] = '' -#app.config['MQTT_PASSWORD'] = '' - -mqtt = Mqtt(app) -socketio = SocketIO(app) -bootstrap = Bootstrap(app) - - -@app.route('/') -def index(): - return render_template('index.html') - - -@socketio.on('publish') -def handle_publish(json_str): - data = json.loads(json_str) - mqtt.publish(data['topic'], data['message'], data['qos']) - - -@socketio.on('subscribe') -def handle_subscribe(json_str): - data = json.loads(json_str) - mqtt.subscribe(data['topic'], data['qos']) - - -@socketio.on('unsubscribe_all') -def handle_unsubscribe_all(): - mqtt.unsubscribe_all() - - -@mqtt.on_message() -def handle_mqtt_message(client, userdata, message): - data = dict( - topic=message.topic, - payload=message.payload.decode(), - qos=message.qos, - ) - socketio.emit('mqtt_message', data=data) - - -@mqtt.on_log() -def handle_logging(client, userdata, level, buf): - # print(level, buf) - pass - - -if __name__ == '__main__': - socketio.run(app, host='0.0.0.0', port=5000, use_reloader=False, debug=True)