Metadata-Version: 2.1
Name: WSocket
Version: 1.1.6
Summary: HTTP and Websocket both supported wsgi server
Home-page: https://github.com/Ksengine/WSocket
Author: Kavindu Santhusa
Author-email: kavindusanthusa@gmail.com
License: MIT
Download-URL: https://pypi.python.org/pypi/WSocket
Keywords: simple,lightweight,WSGI,micro,server,http,websocket,library,python
Platform: any
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 5 - Production/Stable
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3
Provides: WSocket
Description-Content-Type: text/markdown
Requires-Dist: ServeLight

# WSocket
**HTTP and Websocket both supported wsgi server**

[![Downloads](https://pepy.tech/badge/wsocket)](https://pepy.tech/project/wsocket)

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](https://www.github.com/Ksengine/ServeLight)**

###Code to create and run the server looks like this:\
using bottle(install bottle before try)
```python
#!/usr/bin/python
# -*- coding: utf-8 -*-
from bottle import request, Bottle
from wsocket import WebSocketHandler
from wsgiref.simple_server import make_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)

httpd = make_server('localhost',9001,app,handler_class=WebSocketHandler)
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](http://www.wsgi.org/) ( supports web server gateway interface )
 - with web frameworks (any  [WSGI](http://www.wsgi.org/)  framework supported)

> Flask, Django, Pyramid, Bottle supported

**View Documentaion***
### License
Code and documentation are available according to the MIT License (see  [LICENSE](https://github.com/Ksengine/WSocket/blob/master/LICENSE)).


