{ "info": { "author": "Jose Padilla", "author_email": "jpadilla@getblimp.com", "bugtrack_url": null, "classifiers": [], "description": "# django-websocket-request\n\n[![Build Status](https://travis-ci.org/GetBlimp/django-websocket-request.png?branch=master)](https://travis-ci.org/GetBlimp/django-websocket-request) [![PyPI version](https://badge.fury.io/py/django-websocket-request.png)](http://badge.fury.io/py/django-websocket-request)\n\n## Overview\nThis package provides support for transport agnostic routing to allow the Django's request/response lifecycle to automatically WebSocket messages. It borrows a WebSocket message format from [Sails.js](http://sailsjs.org/).\n\n## Installation\n\nInstall using `pip`...\n\n```\n$ pip install django-websocket-request\n```\n\n## Usage\n\n### ws.py\n\n```python\n# Set Django Environment\nos.environ['DJANGO_SETTINGS_MODULE'] = 'django_project.settings'\n\nfrom wsrequest import WebSocketRequest\n\nmessage = '{\"method\": \"GET\", \"url\": \"/api/projects/\"}'\nrequest = WebSocketRequest(message)\nresponse = request.get_response()\n\nprint(response.content)\n\n```\n\n### WebSocket message format\n\nThe method key can be any HTTP method: GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS. The url key is an absolute URL without the domain name. The data key is an optional dictionary in which the key-value pairs in used to create the method\u2019s data payload. The token key is also optional, and used to recreate an HTTP Authorization header, Authorization: JWT YOUR_TOKEN_HERE. If you're using Django REST framework, you might like to check out [django-rest-framework-jwt](https://github.com/GetBlimp/django-rest-framework-jwt).\n\n```json\n{\n \"method\": \"POST\",\n \"url\": \"/api/companies/\",\n \"data\": {\n \"name\": \"Acme Inc.\"\n },\n \"token\": \"MY_JSON_WEB_TOKEN\"\n}\n```\n\n## Live Demo\n\nCheck out [GetBlimp/django-websocket-request-example](https://github.com/GetBlimp/django-websocket-request-example) for an example implementation and a live demo.\n\n## Example implementation with sockjs + tornado\n```python\nimport os\nimport json\n\nfrom tornado import web, ioloop\nfrom sockjs.tornado import SockJSRouter, SockJSConnection\n\n# Set Django Environment\nos.environ['DJANGO_SETTINGS_MODULE'] = 'django_project.settings'\n\nfrom wsrequest import WebSocketRequest\n\n\nclass RESTAPIConnection(SockJSConnection):\n def on_open(self, info):\n self.send(json.dumps({'connected': True}))\n\n def on_message(self, data):\n response = WebSocketRequest(data).get_response()\n self.send(response.content)\n\n\nif __name__ == '__main__':\n import logging\n\n port = 8080\n\n logging.getLogger().setLevel(logging.INFO)\n\n Router = SockJSRouter(RESTAPIConnection, '/ws/api')\n\n app = web.Application(Router.urls)\n app.listen(port)\n\n logging.info(\" [*] Listening on 0.0.0.0:{}\".format(port))\n\n ioloop.IOLoop.instance().start()\n\n```", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/GetBlimp/django-websocket-request", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "django-websocket-request", "package_url": "https://pypi.org/project/django-websocket-request/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-websocket-request/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/GetBlimp/django-websocket-request" }, "release_url": "https://pypi.org/project/django-websocket-request/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "Support for Django's request/response lifecycle to automatically handle WebSocket messages.", "version": "0.1.1" }, "last_serial": 981355, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "d4d883e345b28110199cca2d4259b047", "sha256": "8090b56a62f4e0c00fa59427c5a5dd17ac6e071d3aa85efb2756d3e248509e9a" }, "downloads": -1, "filename": "django_websocket_request-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d4d883e345b28110199cca2d4259b047", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10178, "upload_time": "2014-01-24T15:57:01", "url": "https://files.pythonhosted.org/packages/51/5b/2b68670f152d5744ff3315d26ce816530551d50e3e57500f4ced9e68ad2f/django_websocket_request-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0779e76325c4da81fd35b699f6e9b5a1", "sha256": "9692b5a106352b9d5196bba9cbe25a2c619e698b199bf889bcdcc8358d64be0e" }, "downloads": -1, "filename": "django-websocket-request-0.1.0.tar.gz", "has_sig": false, "md5_digest": "0779e76325c4da81fd35b699f6e9b5a1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9035, "upload_time": "2014-01-24T15:56:58", "url": "https://files.pythonhosted.org/packages/07/e2/8bec05e434c99a14b2db21df82da7d4632e325666893fc37ad38f65b5f75/django-websocket-request-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "be565bbac261ce960be41e97862bb1f8", "sha256": "0c610e06c4c31dead4f63c9f048e4648a1c8f6d2459fe182c9955d0638fb6998" }, "downloads": -1, "filename": "django_websocket_request-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "be565bbac261ce960be41e97862bb1f8", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10368, "upload_time": "2014-01-25T22:01:24", "url": "https://files.pythonhosted.org/packages/f1/89/acc7bfc7267b06832d00553d2277483b2256d2839826ef84ba95f4c9692b/django_websocket_request-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c26a28979bcbee731cfcd270e563a24f", "sha256": "3daadc93a75a9542f83d6e6d267e2626afc1e687fb3d3aae345419f84244175a" }, "downloads": -1, "filename": "django-websocket-request-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c26a28979bcbee731cfcd270e563a24f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9261, "upload_time": "2014-01-25T22:01:20", "url": "https://files.pythonhosted.org/packages/40/8e/3053f9c4b4d887e5983a74483d4ac37dcdaae1c827da30764bc4ac3b23ae/django-websocket-request-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "be565bbac261ce960be41e97862bb1f8", "sha256": "0c610e06c4c31dead4f63c9f048e4648a1c8f6d2459fe182c9955d0638fb6998" }, "downloads": -1, "filename": "django_websocket_request-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "be565bbac261ce960be41e97862bb1f8", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10368, "upload_time": "2014-01-25T22:01:24", "url": "https://files.pythonhosted.org/packages/f1/89/acc7bfc7267b06832d00553d2277483b2256d2839826ef84ba95f4c9692b/django_websocket_request-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c26a28979bcbee731cfcd270e563a24f", "sha256": "3daadc93a75a9542f83d6e6d267e2626afc1e687fb3d3aae345419f84244175a" }, "downloads": -1, "filename": "django-websocket-request-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c26a28979bcbee731cfcd270e563a24f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9261, "upload_time": "2014-01-25T22:01:20", "url": "https://files.pythonhosted.org/packages/40/8e/3053f9c4b4d887e5983a74483d4ac37dcdaae1c827da30764bc4ac3b23ae/django-websocket-request-0.1.1.tar.gz" } ] }