pymqtt


Namepymqtt JSON
Version 0.0.14 PyPI version JSON
download
home_pagehttps://github.com/flask-rabmq/pymqtt
SummaryAdds pymqtt support to your Python application.
upload_time2023-08-09 07:50:02
maintainer
docs_urlNone
authorchenxiaolong
requires_python>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*
licenseMIT
keywords python flask django mqtt
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pymqtt

pymqtt is a mqtt python client library extension meant to facilitate the integration of a MQTT client into your web application. Basically it is a thin wrapper around the paho-mqtt package to simplify MQTT integration in a python application. MQTT is a machine-to-machine (M2M)/”Internet of Things” (IoT) protocol which is designed as a lightweight publish/subscribe messaging transport. It comes very handy when trying to connect multiple IoT devices with each other or monitor and control these devices from one or multiple clients.


## Installing

Install and update using `pip`:

```
$ pip install -U pymqtt
```


## A Simple Example

```python
import logging

from flask import Flask

from pymqtt import Mqtt

logging.basicConfig(format='%(asctime)s %(process)d,%(threadName)s %(filename)s:%(lineno)d [%(levelname)s] %(message)s',
                    datefmt='%Y-%m-%d %H:%M:%S',
                    level=logging.INFO)

logger = logging.getLogger(__name__)

app = Flask(__name__)

app.config.setdefault('MQTT_IP', '127.0.0.1')
app.config.setdefault('MQTT_PORT', 1883)
app.config.setdefault('MQTT_USER', 'user')
app.config.setdefault('MQTT_PASSWORD', 'password')

fmqtt = Mqtt()
fmqtt.config_from_obj(app.config)


@app.route('/')
def hello_world():
    content = 'hello world'
    success = fmqtt.publish('hell world', 'topic', qos=2)
    return 'send %s success %s' % (content, success)


@fmqtt.subscribe(topic='topic', qos=2)
def flask_rabmq_test(body):
    logger.info(body)
    return True


if __name__ == '__main__':
    fmqtt.run()
    app.run()
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/flask-rabmq/pymqtt",
    "name": "pymqtt",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*",
    "maintainer_email": "",
    "keywords": "python flask django mqtt",
    "author": "chenxiaolong",
    "author_email": "cxiaolong6@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e9/6e/9039d9d5d70c7a4a79d741586e99441d7d7e9f01f256584496f1fae56a17/pymqtt-0.0.14.tar.gz",
    "platform": null,
    "description": "# pymqtt\n\npymqtt is a mqtt python client library extension meant to facilitate the integration of a MQTT client into your web application. Basically it is a thin wrapper around the paho-mqtt package to simplify MQTT integration in a python application. MQTT is a machine-to-machine (M2M)/\u201dInternet of Things\u201d (IoT) protocol which is designed as a lightweight publish/subscribe messaging transport. It comes very handy when trying to connect multiple IoT devices with each other or monitor and control these devices from one or multiple clients.\n\n\n## Installing\n\nInstall and update using `pip`:\n\n```\n$ pip install -U pymqtt\n```\n\n\n## A Simple Example\n\n```python\nimport logging\n\nfrom flask import Flask\n\nfrom pymqtt import Mqtt\n\nlogging.basicConfig(format='%(asctime)s %(process)d,%(threadName)s %(filename)s:%(lineno)d [%(levelname)s] %(message)s',\n                    datefmt='%Y-%m-%d %H:%M:%S',\n                    level=logging.INFO)\n\nlogger = logging.getLogger(__name__)\n\napp = Flask(__name__)\n\napp.config.setdefault('MQTT_IP', '127.0.0.1')\napp.config.setdefault('MQTT_PORT', 1883)\napp.config.setdefault('MQTT_USER', 'user')\napp.config.setdefault('MQTT_PASSWORD', 'password')\n\nfmqtt = Mqtt()\nfmqtt.config_from_obj(app.config)\n\n\n@app.route('/')\ndef hello_world():\n    content = 'hello world'\n    success = fmqtt.publish('hell world', 'topic', qos=2)\n    return 'send %s success %s' % (content, success)\n\n\n@fmqtt.subscribe(topic='topic', qos=2)\ndef flask_rabmq_test(body):\n    logger.info(body)\n    return True\n\n\nif __name__ == '__main__':\n    fmqtt.run()\n    app.run()\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Adds pymqtt support to your Python application.",
    "version": "0.0.14",
    "project_urls": {
        "Homepage": "https://github.com/flask-rabmq/pymqtt"
    },
    "split_keywords": [
        "python",
        "flask",
        "django",
        "mqtt"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e96e9039d9d5d70c7a4a79d741586e99441d7d7e9f01f256584496f1fae56a17",
                "md5": "03a8c13d1b75e06ec73d95a6b4d3f13b",
                "sha256": "6d5e17e394d40a2947f5389af55df2f65a742cd2cf58a5559fe39bab472e3f0d"
            },
            "downloads": -1,
            "filename": "pymqtt-0.0.14.tar.gz",
            "has_sig": false,
            "md5_digest": "03a8c13d1b75e06ec73d95a6b4d3f13b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*",
            "size": 4710,
            "upload_time": "2023-08-09T07:50:02",
            "upload_time_iso_8601": "2023-08-09T07:50:02.679481Z",
            "url": "https://files.pythonhosted.org/packages/e9/6e/9039d9d5d70c7a4a79d741586e99441d7d7e9f01f256584496f1fae56a17/pymqtt-0.0.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-09 07:50:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "flask-rabmq",
    "github_project": "pymqtt",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pymqtt"
}
        
Elapsed time: 1.94830s