2022-05-28 13:47:26 +00:00
|
|
|
# socketify.py
|
2022-05-24 19:37:16 +00:00
|
|
|
Fast WebSocket and Http/Https server using CFFI with C API from [uNetworking/uWebSockets](https://github.com/uNetworking/uWebSockets)
|
|
|
|
|
2022-10-27 17:01:34 +00:00
|
|
|
This project aims at High Performance PyPy3 Web Development and WebSockets
|
2022-05-24 19:37:16 +00:00
|
|
|
|
2022-10-27 17:01:34 +00:00
|
|
|
> This project will adapt the full capi from uNetworking/uWebSockets but for now it's just this.
|
2022-10-11 12:33:55 +00:00
|
|
|
|
2022-05-24 19:37:16 +00:00
|
|
|
### Overly simple hello world app
|
|
|
|
```python
|
2022-05-28 13:47:26 +00:00
|
|
|
from socketify import App
|
2022-05-24 19:37:16 +00:00
|
|
|
|
2022-05-25 14:01:56 +00:00
|
|
|
app = App()
|
2022-05-28 13:47:26 +00:00
|
|
|
app.get("/", lambda res, req: res.end("Hello World socketify from Python!"))
|
2022-05-28 19:59:08 +00:00
|
|
|
app.listen(3000, lambda config: print("Listening on port http://localhost:%d now\n" % config.port))
|
2022-05-24 19:37:16 +00:00
|
|
|
app.run()
|
|
|
|
```
|
|
|
|
|
2022-05-28 20:04:35 +00:00
|
|
|
### pip install
|
2022-05-24 19:37:16 +00:00
|
|
|
|
|
|
|
```bash
|
2022-05-28 22:49:16 +00:00
|
|
|
pip install git+https://github.com/cirospaciari/socketify.py.git --global-option=build_ext
|
2022-05-28 20:04:35 +00:00
|
|
|
#or specify PyPy3
|
2022-05-28 22:49:16 +00:00
|
|
|
pypy3 -m pip install git+https://github.com/cirospaciari/socketify.py.git --global-option=build_ext
|
2022-05-29 00:00:21 +00:00
|
|
|
#or in editable mode
|
|
|
|
pypy3 -m pip install -e git+https://github.com/cirospaciari/socketify.py.git@main#egg=socketify
|
2022-05-24 19:37:16 +00:00
|
|
|
```
|
|
|
|
|
2022-05-29 00:00:21 +00:00
|
|
|
### Install via requirements.txt
|
|
|
|
|
|
|
|
requirements.txt file content
|
|
|
|
```text
|
|
|
|
git+https://github.com/cirospaciari/socketify.py.git@main#socketify --global-option="build_ext"
|
|
|
|
```
|
|
|
|
|
|
|
|
install command
|
2022-05-24 19:37:16 +00:00
|
|
|
```bash
|
2022-05-29 00:00:21 +00:00
|
|
|
pip install -r ./requirements.txt
|
|
|
|
#or specify PyPy3
|
|
|
|
pypy3 -m pip install -r ./requirements.txt
|
2022-05-24 19:37:16 +00:00
|
|
|
```
|
2022-05-25 14:01:56 +00:00
|
|
|
|
|
|
|
### SSL version sample
|
|
|
|
``` python
|
2022-05-28 13:47:26 +00:00
|
|
|
from socketify import App, AppOptions
|
2022-05-25 14:01:56 +00:00
|
|
|
|
|
|
|
app = App(AppOptions(key_file_name="./misc/key.pem", cert_file_name="./misc/cert.pem", passphrase="1234"))
|
2022-05-28 13:47:26 +00:00
|
|
|
app.get("/", lambda res, req: res.end("Hello World socketify from Python!"))
|
2022-05-28 19:59:08 +00:00
|
|
|
app.listen(3000, lambda config: print("Listening on port http://localhost:%d now\n" % config.port))
|
2022-05-25 14:01:56 +00:00
|
|
|
app.run()
|
2022-05-28 20:04:35 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Build local from source
|
|
|
|
```bash
|
|
|
|
#clone and update submodules
|
|
|
|
git clone https://github.com/cirospaciari/socketify.py.git
|
|
|
|
cd ./socketify.py
|
|
|
|
git submodule update --init --recursive --remote
|
2022-05-29 00:00:21 +00:00
|
|
|
#install local pip
|
|
|
|
pypy3 -m pip install . --global-option=build_ext #--no-cache-dir is an option
|
|
|
|
#install in editable mode
|
|
|
|
pypy3 -m pip install -e .
|
2022-05-28 20:04:35 +00:00
|
|
|
#if you want to remove
|
|
|
|
pypy3 -m pip uninstall socketify
|
2022-10-11 12:33:55 +00:00
|
|
|
```
|