Mokei
Mokei is a simple asynchronous Python web framework built on aiohttp.
Aiohttp contains a great async web server, with web framework built in, but can be complex when compared to other web frameworks.
Mokei makes setting up your routes as simple as using Flask or FastAPI. It also includes super easy websocket routes with support for text and binary messages, as well as SocketIO-style event handlers.
Quick Start
from mokei import Mokei
app = Mokei()
@app.get('/')
async def hello():
return 'Hello, World!'
if __name__ == '__main__':
app.run()
Return JSON data
When the return type from the handler is a dict, the response is automatically converted to application/json
@app.get('/status')
async def status():
return {
'status': 'OK',
}
Adding Websocket support
Adding a websocket route is as simple as adding a normal get route.
Note that you may send websocket messages to a route or to a single websocket (compare websocket.send_text and data.send_text below)
app = Mokei()
data = app.websocketroute('/data')
@data.onconnect
async def send_welcome_text(websocket):
await websocket.send_text('Welcome!')
@data.ontext
async def relay_text(websocket, text):
# log incoming text and relay to all other websockets
logger.info('Received text %s', text)
await data.send_text(text, exclude=websocket)
SocketIO-style events are also supported. See js/mokei.js for a Javascript handler for Mokei WebSockets.
app = Mokei()
data = app.websocketroute('/data')
@data.on('ping')
async def send_pong(websocket, data):
update_something(websocket)
await websocket.send_event('pong', {'timestamp': time.time()})
Metadata
Release files for mokei 0.2.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mokei-0.2.19.tar.gz | 15.9 kB | Without provenance | Details for mokei-0.2.19.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mokei-0.2.19-py3-none-any.whl | Python 3 | none | any | Details for mokei-0.2.19-py3-none-any.whl |
Total release size: 36.5 kB
Release files / mokei-0.2.19.tar.gz
| Download URL | mokei-0.2.19.tar.gz |
|---|---|
| Size | 15.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26b9405dd63a14ac1b49fb81d63fd7ac45ac63b63aa56c20048e9f4f04356390
|
|
BLAKE2b-256 checksum How to use checksums |
4622d2d29343532ec0b1e83c50bce092c5c9d230157f71b9f42e9ed496c747fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / mokei-0.2.19-py3-none-any.whl
| Download URL | mokei-0.2.19-py3-none-any.whl |
|---|---|
| Size | 20.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
36dee4e3db585792f91e862d4537569b3efc477b07530a1c295a8227ddb012ee
|
|
BLAKE2b-256 checksum How to use checksums |
0ecc926f2b9f978d6e54e47f152a8b77e89ff1d69e4ed9cfca0d9f6acf10d038
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for mokei 0.2.19
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.