added SSL sample in README.md

pull/39/head
Ciro 2022-05-25 11:01:56 -03:00
rodzic 74f098bf50
commit 17c1b5b46b
2 zmienionych plików z 13 dodań i 10 usunięć

Wyświetl plik

@ -5,11 +5,11 @@ Fast WebSocket and Http/Https server using CFFI with C API from [uNetworking/uWe
### Overly simple hello world app
```python
from "uws" import UWSApp
from "uws" import App
app = UWSApp()
app = App()
app.get("/", lambda res, req: res.end("Hello World uWS from Python!"))
app.listen(3000, lambda socket, config: print("Listening on port http://localhost:%s now\n" % str(config.port)))
app.listen(3000, lambda socket, config: print("Listening on port http://localhost:%d now\n" % config.port))
app.run()
```
@ -23,3 +23,13 @@ pip install git+https://github.com/cirospaciari/uWebSockets.py.git
```bash
pypy3 ./hello_world.py
```
### SSL version sample
``` python
from "uws" import App, AppOptions
app = App(AppOptions(key_file_name="./misc/key.pem", cert_file_name="./misc/cert.pem", passphrase="1234"))
app.get("/", plaintext)
app.listen(3000, lambda socket, config: print("Listening on port http://localhost:%d now\n" % config.port))
app.run()
```

Wyświetl plik

@ -483,13 +483,6 @@ class AppListenOptions:
self.host = host
self.options = options
# typedef struct
# {
# int port;
# const char *host;
# int options;
# } uws_app_listen_config_t;
class AppOptions:
def __init__(self, key_file_name=None, cert_file_name=None, passphrase=None, dh_params_file_name=None, ca_file_name=None, ssl_ciphers=None, ssl_prefer_low_memory_usage=0):
if key_file_name != None and not isinstance(key_file_name, str): raise RuntimeError("key_file_name must be an String or None")