fastapi-socketio
Easly integrate socket.io with your FastAPI app.
Installation
Install this plugin using pip:
$ pip install fastapi-socketio
Usage
To add SocketIO support to FastAPI all you need to do is import SocketManager and pass it FastAPI object.
# app.py
from fastapi import FastAPI
from fastapi_socketio import SocketManager
app = FastAPI()
socket_manager = SocketManager(app=app)
Now you can use SocketIO directly from your FastAPI app object.
# socket_handlers.py
from .app import app
@app.sio.on('join')
async def handle_join(sid, *args, **kwargs):
await app.sio.emit('lobby', 'User joined')
Or you can import SocketManager object that exposes most of the SocketIO functionality.
# socket_handlers2.py
from .app import socket_manager as sm
@sm.on('leave')
async def handle_leave(sid, *args, **kwargs):
await sm.emit('lobby', 'User left')
Development
To contribute to this library, first checkout the code. Then create a new virtual environment:
cd fastapi-socketio
python -mvenv venv
source venv/bin/activate
Or if you are using pipenv:
pipenv shell
Now install the dependencies and tests:
pip install -e '.[test]'
To run the tests:
pytest
Run example
To run the examples simply run:
PYTHONPATH=. python examples/app.py
Before running example make sure you have all dependencies installed.
Contributors
For list of contributors please reefer to CONTRIBUTORS.md file in this repository.
Metadata
Release files for fastapi-socketio 0.0.10
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 |
|---|---|---|---|---|
| fastapi-socketio-0.0.10.tar.gz | 7.2 kB | Without provenance | Details for fastapi-socketio-0.0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastapi_socketio-0.0.10-py3-none-any.whl | Python 3 | none | any | Details for fastapi_socketio-0.0.10-py3-none-any.whl |
Total release size: 14.6 kB
Release files / fastapi-socketio-0.0.10.tar.gz
| Download URL | fastapi-socketio-0.0.10.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
202f9b319f010001cbd1114ec92a0d9eb5f5ca9316eae5fd41a6088da0812727
|
|
BLAKE2b-256 checksum How to use checksums |
e114dde9633af2168f1929447c7d8a8947e9371dfca37d58c72d8c1ad686db75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.16
|
Release files / fastapi_socketio-0.0.10-py3-none-any.whl
| Download URL | fastapi_socketio-0.0.10-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11c2bfa3f25d786bd860ed13c892472e86bfeba85e7a0bec4f922ae5e4d8650f
|
|
BLAKE2b-256 checksum How to use checksums |
b54950fe1f72b10c1902fc057e5810f51bffc94c5cab416cf9f16358e71b021a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.16
|
Security for fastapi-socketio 0.0.10
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.