Skip to main content

A simple and lightweight MicroPython web-framework

Project description

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:

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:

@gerent.route("/hello/world", ['POST'])
def hello_world(request):
  return(200, {}, "Hello from gerent framework!")

Gerent backend creates an entry in url linker register:

{'route': '/hello/world', 'methods': ['POST'], 'function': <function hello_world at 0x2000c1c0>}

Url linker contains basic informations about route, avaliable methods and linked function for defined url.
While Gerent client is running:

while True:
  gerent.listen(socket)

it's listening for incoming traffic, analyzing requests and properly responding to client's requests.

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

gerent-0.0.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gerent-0.0.2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file gerent-0.0.2.tar.gz.

File metadata

  • Download URL: gerent-0.0.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for gerent-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b6973bec58dd6bdb6abf46d354bb7efb59c0bf051005bec2bbcca350c0765c2c
MD5 e0422d9a848140d3d57226d98621d1e3
BLAKE2b-256 ebbee96f7766a5eedee49bc19f380e1a7c899ad4fd60e0e303fdd0c8254b9ffe

See more details on using hashes here.

File details

Details for the file gerent-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: gerent-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for gerent-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8b390932abcf35d1e9e83b5ce12abc16e636093f623e7b2788552e0a799bf03c
MD5 1d905dec0d97422dcaa0d42ea91523ea
BLAKE2b-256 84233e5712b6ecc79f34c467d85d644a780d515403b42af6c588b3f81a5f4bf9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page