HTTP and Websocket both supported wsgi server
Project description
WSocket
HTTP and Websocket both supported wsgi server
WSGI Server creates and listens at the HTTP
socket, dispatching the requests to a handler.
Code to create and run the server looks like this:
using bottle
#!/usr/bin/python
# -*- coding: utf-8 -*-
from bottle import request, Bottle
from wsgi import WebSocketHandler
from sl import *
from time import sleep
app = Bottle()
@app.route('/')
def handle_websocket():
wsock = request.environ.get('wsgi.websocket')
if not wsock:
return 'Hello World!'
while True:
message = wsock.receive()
print(message)
wsock.send('Your message was: %r' % message)
sleep(3)
wsock.send('Your message was: %r' % message)
def make_server(application):
server = ThreadingWSGIServer(('', 9001), WebSocketHandler)
server.set_app(application)
return server
httpd = make_server(app)
print('WSGIServer: Serving HTTP on port 9001 ...\n')
try:
httpd.serve_forever()
except:
print('WSGIServer: Server Stopped')
run this code download client.html file open it with browser see how it works! then navigate to http://localhost:9001 You can see Hello World!
Features
- the power of websocket
- fast ( It's very fast )
- simple
- lightweight (simple and lightweight )
- WSGI ( supports web server gateway interface )
- with web frameworks (any WSGI framework supported)
Flask, Django, Pyramid, Bottle supported
View Documentaion*
License
Code and documentation are available according to the MIT License (see LICENSE).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file WSocket-1.0.1.tar.gz
.
File metadata
- Download URL: WSocket-1.0.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a4c61ff091c3253af627371b846b6ac518858cfd24efd36399274abe1b8611a |
|
MD5 | aa4db7029b22d017207d1a7735ae6b9f |
|
BLAKE2b-256 | 9adb8aa98d3dbc60b851bc8cfaab3850b143bc1cc82ad3fbdc0b58fec75548ef |
File details
Details for the file WSocket-1.0.1-py3.7.egg
.
File metadata
- Download URL: WSocket-1.0.1-py3.7.egg
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 871cd9501e5197ccb7341953965eb6cf031734e3e9280f75a8f26dfa90bd340d |
|
MD5 | 2bc5f24ad0deaccacc686b0f76451c71 |
|
BLAKE2b-256 | 88a66c69a23e9e4619b6b22d6a197d062babc9d5458398e081d9f44da1f3e25f |
File details
Details for the file WSocket-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: WSocket-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f906a26aa04c2882238b65bfd3b9f9117151f3286689072b059e604c91c659b |
|
MD5 | 7185b32705011c59688c231337c32148 |
|
BLAKE2b-256 | 16824451b5828ce4565b2662aefeac2840840c742157aaff60573bace11c8fe6 |
File details
Details for the file WSocket-1.0.1-py2.7.egg
.
File metadata
- Download URL: WSocket-1.0.1-py2.7.egg
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ea818b6719a5392871440d61ec5a0adb943ad8fbc5b6ae5bf545a37abea0eeb |
|
MD5 | 76bc27ab1b09c819ada1adaffd8483cf |
|
BLAKE2b-256 | 1eeffe619ffbaac259aaad899a103dcb604bb7934e9eac9aec47fd0d6a913898 |
File details
Details for the file WSocket-1.0.1-py2-none-any.whl
.
File metadata
- Download URL: WSocket-1.0.1-py2-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5ac96d2ea8ecf40472d5df8f35c1843eee08cb5925243490775fbd9e7576d1c |
|
MD5 | 7d9b954621e3341e347cccc1063d089b |
|
BLAKE2b-256 | 51bbf94746ee92939ecf1ea4017d03b37e3cfcfebb9372dc42f292afc27ec923 |