Async Web framework based on Tulip/asyncio
Project description
Vase is a webframework for Tulip/asyncio
~~~~~~~~~~~~~~~~~~~~~~
Inspired by Flask
It currently has a basic WSGI interface and WebSocket support.
A demo websocket app is available here http://vase-chat.herokuapp.com/
Sample echo app
~~~~~~~~~~~~~~~~~
.. code-block:: python
from vase import Vase
app = Vase(__name__)
@app.route(path="/")
def hello(request):
return "Hello Vase!"
@app.endpoint(path="/ws/echo")
class EchoEndpoint:
"""
WebSocket endpoint
Has the following attributes:
`bag` - a dictionary that is shared between all instances of this endpoint
`transport` - used to send messages into the websocket
"""
def on_connect(self):
self.transport.send("You are successfully connected")
def on_message(self, message):
self.transport.send(message)
def on_close(self, exc=None):
print("Connection closed")
if __name__ == '__main__':
app.run()
~~~~~~~~~~~~~~~~~~~~~~
Inspired by Flask
It currently has a basic WSGI interface and WebSocket support.
A demo websocket app is available here http://vase-chat.herokuapp.com/
Sample echo app
~~~~~~~~~~~~~~~~~
.. code-block:: python
from vase import Vase
app = Vase(__name__)
@app.route(path="/")
def hello(request):
return "Hello Vase!"
@app.endpoint(path="/ws/echo")
class EchoEndpoint:
"""
WebSocket endpoint
Has the following attributes:
`bag` - a dictionary that is shared between all instances of this endpoint
`transport` - used to send messages into the websocket
"""
def on_connect(self):
self.transport.send("You are successfully connected")
def on_message(self, message):
self.transport.send(message)
def on_close(self, exc=None):
print("Connection closed")
if __name__ == '__main__':
app.run()
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
Vase-0.1.4.tar.gz
(8.7 kB
view details)
File details
Details for the file Vase-0.1.4.tar.gz
.
File metadata
- Download URL: Vase-0.1.4.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 301dffa64e98fa2fd638b765d0e051b79eed0433551b329a44c2b75857cff0e7 |
|
MD5 | dd61e2b07b0b94eae75ef68ac2e85805 |
|
BLAKE2b-256 | 96bd02cef2d324aa01543165b5ce27cffb746452c6532749272eb62c60982595 |