Skip to main content

mpymodcore

Project description

Code style: black

mpy-modcore - a module framework for MicroPython

The simplest approach to modularize MicroPython projects.

Introduce a defined lifecycle and eventing model for modules / devices for convenient handling of loose coupled modules/ devices

What's new ?

Check CHANGELOG for latest ongoing, or upcoming news and also for known issues and backlog refer to BACKLOG

Web Server included

In package modext.http there are basic HTTP request handling functions.

In package modext.windup is WindUp as included web server.

The WindUp web server is like Apache based on the concept of Filter and Content Generator. What makes WindUp easy extensible; and flexible how requests are processed.

WindUp comes already with a bunch of Filters, e.g. HTML Form data parser, JSON processing, Query parameter extraction, Cookies, Session handling (in-memory), REST stlye URL parameter parser, and extraction, etc.

Multi-tasking processing support of HTTP requests based on fiber (source).

Static Files and JSON response data is processed in fibered mode. Anyway user code is free to redefine this behaviour by setting the fibered parameter to False on request base.

WindUp is in Alpha state and not performance optimized. Anyway response times under 1 secs are already possible.

Secure Role based Access to URL Routes

WindUp supports you to write Role based applications, with a minimal side effort. Refer to the additional Login/Logout module under mod3rd on how to use this.

Dashboard

if mod3rd\admin_windup is enabled the dashboard is available at http://your-ip/main/# (trailing /# is important).

New to fiber ?

Like an async coroutine is a fiber an approach of cooperative multitasking. Whereas objectives are the same.

Pros and Cons? Read more on wikipedia about fiber

Do i need to fiber my code ?

No. Serve traditional as you go, or fiber the code.

Platform

Tested on ESP32 with PSRam and ESP8266 (for latter, see limitations below)

Development status

Alpha state. The API or logical call flow might change without prior notice.

In case your code breaks between two versions check CHANGELOG information first before creating a ticket / issue on github. thanks.

Limitations

  • no asyncio integration as of now
  • with all mod's enabled as shown here in the sample it will not run on ESP8266 due to memory limit. but wlan, softap, and ntp should work

Sample Code

Some sample code can be found in boot.py and under samples.

In order to run the samples sync the folder www and etc from github to the local project folder from where running the samples. If running together with boot.py check for run_not_in_sample_mode and set to False to prevent autostarting WindUp and blocking the socket, or provide your own boot.py.

In oder to run the unsuported modules from the mod3rd folder download this folder from github to the local project folder.

There are hints how to use or test with curl, all using URL http://your-ip/.... Add the following to /etc/hosts to use them more easily. e.g. when your device has the following IP address:

192.168.178.26    your-ip

Reference proof-of-concept project

the garden watering project mpymodcore_watering is the reference proof-of-concept project for mpy-modcode.

it covers in detail:

  • usage of modcore modules
  • modcore eventing modell
  • REST / ajax based application development
  • HTML / javascript user interface devlopment
  • single page app devlopment with 3rd party tools:

Related project

mpy-modcore is the successor of mpyconfigbase

For configuration of automatic startup of WLAN, SoftAP, and WebRepl refer to the source/ sample code also there

Search GitHub for other projects with topic mpy-modcore.

Installation

  • with pip (recommended)

    # install to the current (project) folder

    python3 -m pip install mpymodcore --no-compile --target .

Add the mpy-modcore folders to your .gitignore

License

mpy-modcore is published as dual licensed. read properly.

:heart: Credits

Running on MicroPython, more about the MicroPython project on github :+1:

Developed with Thonny :+1:

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

mpymodcore-0.0.23.tar.gz (89.1 kB view hashes)

Uploaded source

Built Distribution

mpymodcore-0.0.23-py3-none-any.whl (108.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page