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:
- The APIs of existing MicroPython web frameworks have nothing in common with Flask, so existing code needs heavy refactoring and migration is very costly;
- Some frameworks use a lot of resources and do not suit resource-constrained devices like the ESP32, whose memory is only a few hundred KB;
- They lack flexible extension points and cannot meet the specific needs of embedded scenarios.
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:
- Low migration cost: the API design and project structure match Flask completely, so existing Flask code can be migrated without major changes;
- Works in both environments: supports MicroPython (resource-constrained embedded use) and CPython (regular Python);
- Light and efficient: designed for resource-constrained environments, with no redundant middleware (the developer believes embedded scenarios do not need middleware);
- Flexible extension: a modular architecture with custom route converters and custom template engines (a TemplateEngine base class is provided);
- Two processing modes: separate synchronous and asynchronous versions for different concurrency needs.
| Module | Key capabilities |
|---|---|
| Routing | Basic routes, dynamic routes (int and custom types), HTTP method selection, custom route converters (regex, parameter or validation-function style); |
| Request handling | Reading form and JSON data, simple file upload (you parse multipart/form-data yourself, limited to 8 KB); |
| Response handling | Automatic JSON serialisation (list/dict), custom status codes and response headers, redirects, flexible Response/make_response; |
| Template rendering | Supports the utemplate library and custom template engines; a default engine can be set; |
| Project structure | Keeps 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

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