{
  "id": "davescodemusings/thimble",
  "name": "thimble",
  "prettyName": "thimble",
  "description": "A tiny async web framework for MicroPython",
  "version": "",
  "author": "davescodemusings",
  "license": "BSD-2-Clause",
  "tags": [],
  "status": "VALID",
  "official": false,
  "source": "https://github.com/davescodemusings/thimble",
  "updatedAt": "2025-06-28T07:00:09.999Z",
  "page": "https://checkmim.com/packages/davescodemusings+thimble",
  "createdAt": "2025-05-27T04:28:32.703Z",
  "submittedBy": "oliverr",
  "install": {
    "mpremote": "mpremote mip install github:davescodemusings/thimble",
    "mip": "import mip; mip.install(\"github:davescodemusings/thimble\")"
  },
  "readme": "# Thimble\nA tiny web framework for MicroPython.\n\n[![Build thimble](https://github.com/DavesCodeMusings/thimble/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/DavesCodeMusings/thimble/actions/workflows/build.yml)\n\n## What is it?\nThimble is similar in spirit to Flask, but scaled way back to fit on a microcontroller. Basically, you can create a web application using functions and routes. It's more robust than the typical MicroPython web server example code. But, there's a lot of features it lacks when compared to a full-featured web application framework. Still, for something that runs on a five dollar microcontroller, it's pretty sweet.\n\n## How can I use it?\nThimble is a class with a route() method and a run() method. You add routes similar to the way you would with Flask and then call a run() method to start listening.\n\nCopy thimble.py to your MicroPython powered microcontroller (or install with MIP). Use main.py to test. Customize with your own functions and routes.\n\nContents of main.py:\n\n```py\nfrom thimble import Thimble\n\napp = Thimble() \n\n@app.route(\"/\")\ndef hello(req):\n    return \"Hello World\"\n\n@app.route(\"/gpio/<digit>\")\ndef gpio(req, num):\n    return f\"Hello GPIO {num}\"\n\napp.run(debug=True)\n```\n\nNow, point your web browser to the IP of your device on the default port of 80 and you should see 'Hello World'. Using the URL path of _/gpio/2_ should return 'Hello GPIO 2'.\n\nThere are more complex examples in the [examples](https://github.com/DavesCodeMusings/thimble/examples) subdirectory.\n\nSee [the wiki](https://github.com/DavesCodeMusings/thimble/wiki) for examples in a step by step tutorial format.\n\n## Can it serve static web pages?\nAs we say here in Wisconsin: \"Oh yah, you betcha!\" You can put your static files in `/static` on your flash filesystem and they will be served up just like any other web server, though a bit slower.\n\nYou can save space by compressing static files with GZIP and adding a `.gzip` extension. These files will be sent with a 'Content-Encoding: gzip' header that will tell the web browser to decompress upon receipt. For example, something like _script-library.js_ could be compressed and stored as _script-library.js.gzip_. Then, when a request is made for _script-library.js_, Thimble will send the contents of _script-library.js.gzip_ and add the Content-Encoding header.\n\n## What pitfalls do I need to be aware of?\nUsing the example main.py assumes that networking is already configured by a boot.py that you supply. Thimble won't work without it. If you need help with wifi connections, see my example under [lolin32oled](https://github.com/DavesCodeMusings/esp/tree/main/lolin32oled)\n\nThimble has been around for a while, but may have a few bugs lurking. If you find one, add a Github issue and I'll see if I can fix it.\n\n## Will it run on Microcontroller X?\nCode is being developed and tested using an ESP32 Devkit V1 clone with MicroPython 1.24. Occasionally, I will run it on an ESP32-C3 or ESP8266. It may or may not work with other devices.\n\n## How do I install it?\nUsing mpremote on Windows, do this:\n```\npy -m mpremote connect PORT mip install github:DavesCodeMusings/thimble\n```\n\n_where PORT is something like COM4 (or whatever shows up in Device Manager for your microcontroller.)_\n\nFor Linux mpremote, do this:\n```\nmpremote connect PORT mip install github:DavesCodeMusings/thimble\n```\n\n_where PORT is something like /dev/ttyUSB0 (or whatever shows up in your `dmesg` output when you plug the device in.)_\n\nOr just download directly from https://raw.githubusercontent.com/DavesCodeMusings/thimble/main/thimble.py and place it in your device's /lib directory.\n\n## Show me the docs!\n* [Documentation of the Thimble Class](https://davescodemusings.github.io/thimble/)\n* [Coding Examples](https://github.com/DavesCodeMusings/thimble/tree/main/examples)\n"
}