Skip to main content

HTTP and Websocket both supported wsgi server

Project description

WSocket

HTTP and Websocket both supported wsgi server

Server(WSGI) creates and listens at the HTTP socket, dispatching the requests to a handler. this is only use standard python libraries. also: this is a plugin to ServerLight Framework.

for a better experiense install servelight

###Code to create and run the server looks like this:
using bottle(install bottle before try)

#!/usr/bin/python
# -*- coding: utf-8 -*-
from bottle import request, Bottle
from wsgi import WebSocketHandler, server
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):
    myserver = server.ThreadingWSGIServer(('', 9001), WebSocketHandler)
    myserver.set_app(application)
    return myserver

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

WSocket-1.1.4.tar.gz (5.9 kB view details)

Uploaded Source

Built Distributions

WSocket-1.1.4-py3.7.egg (12.1 kB view details)

Uploaded Source

WSocket-1.1.4-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

WSocket-1.1.4-py2.7.egg (12.2 kB view details)

Uploaded Source

WSocket-1.1.4-py2-none-any.whl (9.0 kB view details)

Uploaded Python 2

File details

Details for the file WSocket-1.1.4.tar.gz.

File metadata

  • Download URL: WSocket-1.1.4.tar.gz
  • Upload date:
  • Size: 5.9 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

Hashes for WSocket-1.1.4.tar.gz
Algorithm Hash digest
SHA256 d674d941429a8d56bb9ca3a9268f781a269c502a169743a77a44922ee57b37c7
MD5 5b09444f230bd2b4986337b19365cf5d
BLAKE2b-256 b249e4c294493a9246b0b5326fb6c8cf14392de16442ac0554694a58ef3da110

See more details on using hashes here.

File details

Details for the file WSocket-1.1.4-py3.7.egg.

File metadata

  • Download URL: WSocket-1.1.4-py3.7.egg
  • Upload date:
  • Size: 12.1 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

Hashes for WSocket-1.1.4-py3.7.egg
Algorithm Hash digest
SHA256 bffd533b666361266303a697c0d293c7bfff2b5e8c72236c01036bcfb36e780c
MD5 66a830f443b8d22a73c0afe919ce88b3
BLAKE2b-256 ee251828af1954c6f51d92ee2e58cc468358803f9fe8a4919412745c922fd942

See more details on using hashes here.

File details

Details for the file WSocket-1.1.4-py3-none-any.whl.

File metadata

  • Download URL: WSocket-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.0 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

Hashes for WSocket-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 84341bbd5c77964313f81cc522ddbb67cab5282b7be05d3053a270d995815312
MD5 820e4027f1b9c6a382af3b1930555477
BLAKE2b-256 533a54fef4bdd3aa212e059d287f8522fa892cd782de13dc47b98bef9b1373a7

See more details on using hashes here.

File details

Details for the file WSocket-1.1.4-py2.7.egg.

File metadata

  • Download URL: WSocket-1.1.4-py2.7.egg
  • Upload date:
  • Size: 12.2 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

Hashes for WSocket-1.1.4-py2.7.egg
Algorithm Hash digest
SHA256 463a164839e2fa9a2f8ada969adff1678af48bb8c9fc970685dace14914d7919
MD5 fdbba43719ba182d106685c7e3fd923d
BLAKE2b-256 6c79885dde6c41965eaa01e6fa371dc883e8f66e248ae046a995b4a18ef3699d

See more details on using hashes here.

File details

Details for the file WSocket-1.1.4-py2-none-any.whl.

File metadata

  • Download URL: WSocket-1.1.4-py2-none-any.whl
  • Upload date:
  • Size: 9.0 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

Hashes for WSocket-1.1.4-py2-none-any.whl
Algorithm Hash digest
SHA256 5f80c8c5b8b37d6752c3c5d640bfd91cce5340207c56ad644c007b59fd5a5e97
MD5 8e48fd47077647113b60b69064207449
BLAKE2b-256 b7670a3d7d9003853f35a8c4b7af7eff28ce5ce0d415b3313c5c61a770a305b4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page