Labs / Board Reviews & Technical Insights

Flask on the ESP32: MicroFlask, an Embedded Web Framework Built by a High School Student

Author: Zhuang Xiaoman · Source: Freak Embedded on WeChat, published 2026-03-22 · License: CC BY 4.0

Contents

The uPyPi package index recently added a lightweight web framework developed independently by a high school student in China: MicroFlask, and its asynchronous version MicroFlask_Async.

While teaching himself Python web development, this high school developer was won over by how simple and efficient the Flask framework is. But when he tried to move his own small Flask projects onto MicroPython embedded devices such as the ESP32, he hit a core problem:

Wanting "more people to be able to run Flask code on a microcontroller", he used his spare time after classes to build this Flask-style MicroPython web framework from scratch, and finally open-sourced it on the uPyPi package index.

(The original article shows the uPyPi pages of the two packages here, microflask and microflask_async, version 0.0.20260321, updated 2026-03-22; their descriptions are translated below.)

✨ What is MicroFlask?

MicroFlask (the synchronous microflask.py and the asynchronous MicroFlask_Async/microflask_async.py) is a lightweight Flask-style web framework. Its core goal is to speed up migrating Flask projects and developing web interfaces. It is designed to be open and extensible, targets MicroPython first (embedded devices such as the ESP32), and also works under CPython.

Put simply, it is a Flask-style web framework made to measure for MicroPython (on microcontrollers like the ESP32). It has one core goal: the Flask code you wrote before should run directly on an embedded device with almost no changes!

Core features:

ModuleKey capabilities
RoutingBasic routes, dynamic routes (int and custom types), HTTP method selection, custom route converters (regex, parameter or validation-function style);
Request handlingReading form and JSON data, simple file upload (you parse multipart/form-data yourself, limited to 8 KB);
Response handlingAutomatic JSON serialisation (list/dict), custom status codes and response headers, redirects, flexible Response/make_response;
Template renderingSupports the utemplate library and custom template engines; a default engine can be set;
Project structureKeeps Flask's static/templates directory structure; the static file path can be customised;

🚀 How easy is it to get started? Here are some examples

(These examples were screenshots in the original article; they are typed out here as code.)

Basic synchronous app

from microflask import *

app = Flask(__name__)

@app.route('/')
def hello(request):
    return "Hello, MicroFlask!"

@app.route('/user/<name>')
def user(request):
    name=request.view_args.get("name")
    return f"Hello, {name}!"

if __name__ == '__main__':
    app.run()

Asynchronous app

from microflask_async import *

app = Flask(__name__)

@app.route('/')
def hello(request):
    return "Hello, Async MicroFlask!"

@app.route('/api/data')
def get_data(request):
    return {"message": "Async data response"}

if __name__ == '__main__':
    app.run()

Routing

Basic routes

@app.route('/')
def index(request):
    return "Home Page"

@app.route('/about')
def about(request):
    return "About Page"

Dynamic routes

@app.route('/user/<username>')
def show_user(req):
    username=req.view_args.get("username")
    return f"User: {username}"

@app.route('/post/<int:post_id>')
def show_post(req):
    post_id=req.view_args.get("post_id")
    return f"Post ID: {post_id}"

HTTP methods

@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        return do_login()
    else:
        return show_login_form()

Template rendering

Basic template use

from microflask import render_template

@app.route('/')
def index():
    return render_template('index.html')

Using a template engine

@app.route('/')
def index():
    return render_template('index.html',template_engine=SimpleTemplateEngine())

Setting the default template engine: to use UTemplateEngine(), make sure the utemplate library has been downloaded and can be imported.

utemplate_engine = UTemplateEngine(pkg=None, dir="demo_templates", loader_type="source")
Response.set_default_template_engine(utemplate_engine)
@app.route('/')
def index():
    return render_template('index.html')

How to install

The library is on upypi: https://upypi.net/; search for: microflask

Searching for microflask on the MicroPython package index

Open the package's detail page and copy the install command:

# Local install
mpremote mip install https://upypi.net/pkgs/microflask/0.0.20260321

# Remote install (on the board)
mip.install("https://upypi.net/pkgs/microflask/0.0.20260321")

# The asynchronous version
mpremote mip install https://upypi.net/pkgs/microflask_async/0.0.20260321