{"id":13802094,"url":"https://github.com/DavesCodeMusings/thimble","last_synced_at":"2025-05-13T12:32:22.606Z","repository":{"id":61326640,"uuid":"549355100","full_name":"DavesCodeMusings/thimble","owner":"DavesCodeMusings","description":"A tiny web framework for MicroPython","archived":false,"fork":false,"pushed_at":"2025-03-28T20:44:58.000Z","size":253,"stargazers_count":18,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T21:23:27.398Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DavesCodeMusings.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-11T04:00:19.000Z","updated_at":"2025-03-28T20:45:01.000Z","dependencies_parsed_at":"2023-01-21T11:15:55.614Z","dependency_job_id":"63bfaf09-f637-448d-9fa6-d6bcd0d6a9b1","html_url":"https://github.com/DavesCodeMusings/thimble","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavesCodeMusings%2Fthimble","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavesCodeMusings%2Fthimble/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavesCodeMusings%2Fthimble/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavesCodeMusings%2Fthimble/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DavesCodeMusings","download_url":"https://codeload.github.com/DavesCodeMusings/thimble/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253942609,"owners_count":21988098,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:01:35.711Z","updated_at":"2025-05-13T12:32:22.585Z","avatar_url":"https://github.com/DavesCodeMusings.png","language":"Python","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/\u003cdigit\u003e\")\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","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDavesCodeMusings%2Fthimble","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDavesCodeMusings%2Fthimble","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDavesCodeMusings%2Fthimble/lists"}