Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomson601/gerent
Gerent is a simple and lightweight web-framework for MicroPython.
https://github.com/tomson601/gerent
esp8266 micropython pypi-package raspberry-pi-pico
Last synced: 3 days ago
JSON representation
Gerent is a simple and lightweight web-framework for MicroPython.
- Host: GitHub
- URL: https://github.com/tomson601/gerent
- Owner: Tomson601
- License: mit
- Created: 2023-02-06T16:45:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-02-12T00:16:02.000Z (over 1 year ago)
- Last Synced: 2024-10-17T17:25:42.468Z (21 days ago)
- Topics: esp8266, micropython, pypi-package, raspberry-pi-pico
- Language: Python
- Homepage: https://pypi.org/project/gerent/
- Size: 48.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gerent
Gerent is a simple and lightweight web-framework for MicroPython.# pypi link:
https://pypi.org/project/gerent/# TODO:
- beautify pyproject.toml
- ✅ add post and put methods
- ✅ add custom http_headers option
- create docs (how does it work, pictures)
- add favicon.ico support
- ✅ create API root, with all url's
- add examples
- beutify micropython code?
- add unitest tests
- beautify web root site, add unified style
- query params
- optimize create_root_site# Currently supported devices:
- Raspberry Pi Pico W
- ESP8266# Example:
```python
import gerent, socket@gerent.route("/hello/world")
def hello_world(request):
return(200, {}, "Hello from gerent framework!")# create socket
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]s = socket.socket()
s.bind(addr)
s.listen(1)# run gerent client
while True:
gerent.listen(s)
```
# Docs:
How does it work?
While defining routes, for example:
```python
@gerent.route("/hello/world", ['POST'])
def hello_world(request):
return(200, {}, "Hello from gerent framework!")
```
Gerent backend creates an entry in url linker register:
```python
{'route': '/hello/world', 'methods': ['POST'], 'function': }
```
Url linker contains basic informations about route, avaliable methods and linked function for defined url.
While Gerent client is running:
```python
while True:
gerent.listen(socket)
```
it's listening for incoming traffic, analyzing requests and properly responding to client's requests.