https://github.com/pavelrevak/uhttp
uHTTP simple HTTP server for micropython
https://github.com/pavelrevak/uhttp
http http-server micropython python
Last synced: about 2 months ago
JSON representation
uHTTP simple HTTP server for micropython
- Host: GitHub
- URL: https://github.com/pavelrevak/uhttp
- Owner: pavelrevak
- Created: 2023-12-27T13:40:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-27T11:33:02.000Z (over 2 years ago)
- Last Synced: 2025-01-13T08:46:08.010Z (over 1 year ago)
- Topics: http, http-server, micropython, python
- Language: Python
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# uHTTP: micro HTTP server and client
Minimalist HTTP libraries for MicroPython and CPython.
## Features
- MicroPython and CPython compatible
- Low-level POSIX socket implementation
- Fully synchronous (no async/await, no threading) but handles multiple simultaneous connections
- Memory-efficient: works with low memory on MCUs
- SSL/TLS support for HTTPS
- IPv6 and dual-stack support
## Packages
The library is split into two independent packages:
### [uhttp-server](https://github.com/cortexm/uhttp-server)
- HTTP server with keep-alive, streaming, event mode
### [uhttp-client](https://github.com/cortexm/uhttp-client)
- HTTP client with keep-alive, auth, cookies
## Installation
```bash
# Install only what you need
pip install uhttp-server
pip install uhttp-client
```
For MicroPython, copy `uhttp/server.py` and/or `uhttp/client.py` from the respective repository to your device.
## Quick Start
### Server
```python
from uhttp.server import HttpServer
server = HttpServer(port=8080)
while True:
client = server.wait()
if client:
client.respond({'message': 'Hello from uHTTP!'})
```
### Client
```python
from uhttp.client import HttpClient
with HttpClient('https://httpbin.org') as client:
response = client.get('/get').wait()
print(response.json())
```
## Documentation
- [Server documentation](https://github.com/cortexm/uhttp-server#readme)
- [Client documentation](https://github.com/cortexm/uhttp-client#readme)
## License
MIT