H2O HTTP server library
Project description
The pyh2o module provides Python binding for the H2O HTTP server. Specifically, it provides high performance HTTP 1/2 and websocket server for Python.
Installation
pip install pyh2o
Development
Clone the repository, initialize submodules by git submodule update --init --recursive
.
Build:
python setup.py build
Test:
python setup.py test
Clean:
python setup.py clean
End to end test brings up a real server and make requests to it.
Example
Below is an example of serving static content.
import h2o
import socket
class Handler(h2o.Handler):
def on_req(self):
self.res_status = 200
self.send_inline(b'Hello, world!')
return 0
config = h2o.Config()
host = config.add_host(b'default', 65535)
host.add_path(b'/plaintext').add_handler(Handler)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
sock.bind(('127.0.0.1', 8888))
sock.listen(0)
loop = h2o.Loop()
loop.start_accept(sock.fileno(), config)
while loop.run() == 0:
pass
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
pyh2o-0.0.4.tar.gz
(16.7 MB
view hashes)
Built Distributions
Close
Hashes for pyh2o-0.0.4-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4bff91427558901ee9b3c5e99b89de9f705a4d962a9d74615c707720d21bcae |
|
MD5 | 57d42b16e3e95157001c4d56b9a2f58b |
|
BLAKE2b-256 | 47041277ecfa15c89d8ee65d262d45ffdc6800931be0e8b94853531b5ca7da0c |
Close
Hashes for pyh2o-0.0.4-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e55ba992ba30fb50f3e13ada9ad8b48e8d3ac5c1efee1a715a82546a26a22481 |
|
MD5 | 65ad704363ad20fcf488da594d0e28f2 |
|
BLAKE2b-256 | 4fe029ecc40cb0fc1e8d73a653b6a85ef19d881b2453a7bbd455f1f1c3684d04 |