a simple HTTP server using functional principles for Micropython and CPython
Project description
micro_http_server
a simple http server for micropython and CPython which also happens to be fast
examples
def my_post_handler(url, data) -> tuple:
code, hdrs = 404, {}
if url == "/users":
for k, v in data.items():
DB[k] = v
code = 200
return code, "", hdrs
def my_get_handler(url, data) -> tuple:
return 200, "hello world!", {}
async def my_handle_client(reader, writer):
handlers = {
"get": my_get_handler,
"post": my_post_handler,
}
await userver.handle_client(reader, writer, handlers)
await userver.finalise_client(reader, writer)
async def main():
loop.create_task(asyncio.start_server(my_handle_client, "0.0.0.0", 3000))
speed
Not a design consideration, but. Benchmarking a simple GET request handler, one request takes ~200 usec user time. Running on a Macbook M1, a single core can serve approx 6000 requests/sec.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file micro_http_server-0.1.1.tar.gz.
File metadata
- Download URL: micro_http_server-0.1.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7412247c2e9527d9d9aaec7e539a7a274e3e0612788a5321b456868da450f257
|
|
| MD5 |
71bf0fbc23ed6a2134ef09e9b7f82e35
|
|
| BLAKE2b-256 |
2eb182a36e3236291bb03a4b7778696648847798eb10d00a82dde2068e67dcbc
|
File details
Details for the file micro_http_server-0.1.1-py3-none-any.whl.
File metadata
- Download URL: micro_http_server-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39542194378a35d8fafed498c7b97c6b0fa17df4a648a9d721e802fed3fe17f4
|
|
| MD5 |
5cb4ed4f199e08c6de1d5e4967232ee4
|
|
| BLAKE2b-256 |
ffbbc3d36bcd8eed814183009f433dc709fa9b8e50450964c61f4ff23e092645
|