microweb 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- microweb/cli.py +24 -9
- microweb/firmware/ESP8266_GENERIC-20250415-v1.25.0.bin +0 -0
- {microweb-0.1.1.dist-info → microweb-0.1.2.dist-info}/METADATA +67 -22
- {microweb-0.1.1.dist-info → microweb-0.1.2.dist-info}/RECORD +8 -6
- microweb-0.1.2.dist-info/licenses/LICENSE +21 -0
- {microweb-0.1.1.dist-info → microweb-0.1.2.dist-info}/WHEEL +0 -0
- {microweb-0.1.1.dist-info → microweb-0.1.2.dist-info}/entry_points.txt +0 -0
- {microweb-0.1.1.dist-info → microweb-0.1.2.dist-info}/top_level.txt +0 -0
microweb/cli.py
CHANGED
@@ -215,33 +215,45 @@ def cli():
|
|
215
215
|
@cli.command()
|
216
216
|
@click.option('--port', default=None, help='Serial port, e.g., COM10')
|
217
217
|
@click.option('--erase', is_flag=True, help='Erase all flash before writing firmware')
|
218
|
-
|
219
|
-
|
218
|
+
@click.option('--esp8266', is_flag=True, help='Flash ESP8266 firmware instead of ESP32')
|
219
|
+
@click.option('--firmware', type=click.Path(exists=True), help='Custom firmware .bin file to flash')
|
220
|
+
def flash(port, erase, esp8266, firmware):
|
221
|
+
"""Flash MicroPython and MicroWeb to the ESP32 or ESP8266."""
|
220
222
|
if not port:
|
221
223
|
ports = [p.device for p in serial.tools.list_ports.comports()]
|
222
224
|
port = ports[0] if ports else None
|
223
225
|
if not port:
|
224
|
-
print_colored("No
|
226
|
+
print_colored("No ESP device found. Specify --port, e.g., --port COM10.", color='red')
|
225
227
|
return
|
228
|
+
|
229
|
+
chip_name = "ESP8266" if esp8266 else "ESP32"
|
230
|
+
if firmware:
|
231
|
+
firmware_path = os.path.abspath(firmware)
|
232
|
+
print_colored(f"Using custom firmware: {firmware_path}", color='cyan')
|
233
|
+
else:
|
234
|
+
firmware_file = f"{chip_name}_GENERIC-20250415-v1.25.0.bin"
|
235
|
+
firmware_path = pkg_resources.resource_filename('microweb', f'firmware/{firmware_file}')
|
236
|
+
|
226
237
|
if erase:
|
227
|
-
print_colored("You requested --erase. This will erase ALL data on the
|
238
|
+
print_colored(f"You requested --erase. This will erase ALL data on the {chip_name}!", color='yellow')
|
228
239
|
confirm = input("Type 'erase' to continue, or anything else to cancel: ")
|
229
240
|
if "erase" not in confirm.lower():
|
230
241
|
print_colored("Erase cancelled.", color='yellow')
|
231
242
|
return
|
232
|
-
print_colored(f"Erasing all flash on {port}...", color='yellow')
|
243
|
+
print_colored(f"Erasing all flash on {port} ({chip_name})...", color='yellow')
|
233
244
|
esptool.main(['--port', port, 'erase_flash'])
|
245
|
+
|
234
246
|
try:
|
235
247
|
print_colored(f"Checking for MicroPython on {port}...", color='blue')
|
236
248
|
if check_micropython(port):
|
237
249
|
print_colored(f"MicroPython detected on {port}. Skipping firmware flash.", color='green')
|
238
250
|
else:
|
239
|
-
firmware_path = pkg_resources.resource_filename('microweb', 'firmware/ESP32_GENERIC-20250415-v1.25.0.bin')
|
240
251
|
if not os.path.exists(firmware_path):
|
241
|
-
print_colored(f"Error: Firmware file not found at {firmware_path}.
|
252
|
+
print_colored(f"Error: Firmware file not found at {firmware_path}.", color='red')
|
242
253
|
return
|
243
|
-
print_colored(f"Flashing firmware on {port}...", color='blue')
|
254
|
+
print_colored(f"Flashing {chip_name} firmware on {port}...", color='blue')
|
244
255
|
esptool.main(['--port', port, 'write_flash', '-z', '0x1000', firmware_path])
|
256
|
+
|
245
257
|
print_colored("Uploading core files...", color='blue')
|
246
258
|
core_files = [
|
247
259
|
('firmware/boot.py', 'boot.py'),
|
@@ -255,12 +267,15 @@ def flash(port, erase):
|
|
255
267
|
print_colored(f"Error: Source file {src_path} not found.", color='red')
|
256
268
|
return
|
257
269
|
upload_file(src_path, port, destination=dest)
|
270
|
+
|
258
271
|
print_colored("Verifying uploaded files...", color='blue')
|
259
272
|
verify_files(port, [dest for _, dest in core_files])
|
260
|
-
print_colored("MicroWeb flashed successfully", color='green')
|
273
|
+
print_colored(f"MicroWeb flashed successfully to {chip_name}", color='green')
|
274
|
+
|
261
275
|
except Exception as e:
|
262
276
|
print_colored(f"Error during flash: {e}", color='red')
|
263
277
|
|
278
|
+
|
264
279
|
@cli.command()
|
265
280
|
@click.argument('file')
|
266
281
|
@click.option('--port', default=None, help='Serial port, e.g., COM10')
|
Binary file
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: microweb
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.2
|
4
4
|
Summary: A web server framework for MicroPython . Easily build and deploy web applications using MicroPython.
|
5
5
|
Home-page: https://github.com/ishanoshada/microweb
|
6
|
-
Author:
|
6
|
+
Author: Ishan Oshada
|
7
7
|
Keywords: micropython,esp32,web server,embedded,iot,http,microcontroller,python
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
@@ -11,6 +11,7 @@ Classifier: Operating System :: OS Independent
|
|
11
11
|
Classifier: Topic :: Software Development :: Embedded Systems
|
12
12
|
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
13
13
|
Description-Content-Type: text/markdown
|
14
|
+
License-File: LICENSE
|
14
15
|
Requires-Dist: pyserial
|
15
16
|
Requires-Dist: esptool
|
16
17
|
Requires-Dist: click
|
@@ -20,6 +21,7 @@ Dynamic: description
|
|
20
21
|
Dynamic: description-content-type
|
21
22
|
Dynamic: home-page
|
22
23
|
Dynamic: keywords
|
24
|
+
Dynamic: license-file
|
23
25
|
Dynamic: requires-dist
|
24
26
|
Dynamic: summary
|
25
27
|
|
@@ -87,6 +89,7 @@ With MicroWeb, you get routing, templates, JSON, static files, and more—making
|
|
87
89
|
- [Example Usage](#example-usage)
|
88
90
|
- [Minimal Example (`tests/2/app.py`)](#minimal-example-tests2apppy)
|
89
91
|
- [Static Files and Templates Example (`tests/1/app.py`)](#static-files-and-templates-example-tests1apppy)
|
92
|
+
- [Portfolio Demo (`tests/portfolio/`)](#portfolio-demo-testsportfolio)
|
90
93
|
- [Wi-Fi Configuration](#wi-fi-configuration)
|
91
94
|
- [Accessing the Web Server](#accessing-the-web-server)
|
92
95
|
- [CLI Tool Usage Examples](#cli-tool-usage-examples)
|
@@ -96,7 +99,7 @@ With MicroWeb, you get routing, templates, JSON, static files, and more—making
|
|
96
99
|
- [Contributing](#contributing)
|
97
100
|
- [License](#license)
|
98
101
|
|
99
|
-
|
102
|
+

|
100
103
|
|
101
104
|
## Features
|
102
105
|
|
@@ -109,7 +112,7 @@ With MicroWeb, you get routing, templates, JSON, static files, and more—making
|
|
109
112
|
- **MicroPython Detection**: Verifies MicroPython before running scripts.
|
110
113
|
- **Easy Cleanup**: Remove all files from the ESP32 home directory using `microweb remove --port COM10 --remove`—try this if you need to reset or clean up your device.
|
111
114
|
|
112
|
-

|
115
|
+

|
113
116
|
|
114
117
|
---
|
115
118
|
## Installation
|
@@ -131,20 +134,30 @@ pip install .
|
|
131
134
|
|
132
135
|
> **Note:** The workspace does not contain a git repository. If you want to contribute or track changes, initialize one with `git init`.
|
133
136
|
|
137
|
+
|
134
138
|
---
|
135
139
|
|
136
140
|
## Usage
|
137
141
|
|
138
|
-
### Flashing the ESP32
|
139
|
-
|
140
142
|
Flash MicroPython and MicroWeb:
|
141
143
|
|
142
144
|
```bash
|
143
145
|
microweb flash --port COM10
|
144
146
|
```
|
145
147
|
|
146
|
-
|
147
|
-
|
148
|
+
#### Options:
|
149
|
+
|
150
|
+
* `--erase`
|
151
|
+
Erase the entire flash memory before flashing firmware.
|
152
|
+
|
153
|
+
* `--esp8266`
|
154
|
+
Flash ESP8266 firmware instead of the default ESP32.
|
155
|
+
|
156
|
+
* `--firmware firmware.bin`
|
157
|
+
Use a custom `.bin` firmware file. This overrides the default firmware for ESP32 or ESP8266 ( any ).
|
158
|
+
|
159
|
+
|
160
|
+
|
148
161
|
|
149
162
|
---
|
150
163
|
|
@@ -156,15 +169,35 @@ Upload and run a MicroPython script:
|
|
156
169
|
microweb run app.py --port COM10
|
157
170
|
```
|
158
171
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
- Validates the `.py` file and checks for MicroPython.
|
172
|
+
- Validates your `.py` file and checks for MicroPython on the device.
|
163
173
|
- Uploads and executes the script.
|
174
|
+
- Checks and uploads only changed files by default.
|
164
175
|
- Prompts to run `microweb flash` if MicroPython is not detected.
|
176
|
+
- After running `app.run()`, the ESP32 will host a Wi-Fi access point (AP) if it cannot connect to a configured network. You can then connect your device to this AP and access the web server using the ESP32's IP address (typically `http://192.168.4.1` in AP mode).
|
165
177
|
|
166
178
|
---
|
167
179
|
|
180
|
+
### Boot Script Management
|
181
|
+
|
182
|
+
You can configure your ESP32 to automatically start your application after any power cycle or reset by managing the `boot.py` file:
|
183
|
+
|
184
|
+
- **Add boot script (auto-run on power-up):**
|
185
|
+
```bash
|
186
|
+
microweb run app.py --add-boot --port COM10
|
187
|
+
```
|
188
|
+
This uploads a `boot.py` that will auto-run your app every time the ESP32 is powered on or reset. After upload, you can disconnect the ESP32 from your computer and power it from any source; the server will start automatically.
|
189
|
+
|
190
|
+
- **Remove boot script:**
|
191
|
+
```bash
|
192
|
+
microweb run app.py --remove-boot --port COM10
|
193
|
+
```
|
194
|
+
This removes the `boot.py` file, so your app will not auto-run on power-up.
|
195
|
+
|
196
|
+
---
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
168
201
|
## Example Usage
|
169
202
|
|
170
203
|
### Minimal Example (`tests/2/app.py`)
|
@@ -254,6 +287,21 @@ app.run()
|
|
254
287
|
|
255
288
|
---
|
256
289
|
|
290
|
+
### Portfolio Demo (`tests/portfolio/`)
|
291
|
+
|
292
|
+
The `tests/portfolio/` directory contains a full-featured portfolio web app built with MicroWeb, demonstrating:
|
293
|
+
|
294
|
+
- Multi-page routing (`/`, `/about`, `/projects`, `/contact`)
|
295
|
+
- Dynamic template rendering with variables
|
296
|
+
- Static assets (CSS, JS, images)
|
297
|
+
- API endpoints (e.g., `/api/info` returns JSON)
|
298
|
+
- Responsive, animated UI using HTML/CSS/JS
|
299
|
+
- Example of serving a personal portfolio from an ESP32
|
300
|
+
|
301
|
+
See `tests/portfolio/app.py` and the `static/` folder for a complete, ready-to-deploy example.
|
302
|
+
|
303
|
+
---
|
304
|
+
|
257
305
|
## Wi-Fi Configuration
|
258
306
|
|
259
307
|
Configure Wi-Fi via:
|
@@ -322,6 +370,7 @@ For more details, run `microweb --help`.
|
|
322
370
|
|
323
371
|
## Project Structure
|
324
372
|
|
373
|
+
|
325
374
|
```
|
326
375
|
microweb/
|
327
376
|
├── microweb/
|
@@ -332,18 +381,13 @@ microweb/
|
|
332
381
|
│ ├── cli.py
|
333
382
|
│ ├── firmware/
|
334
383
|
│ │ ├── ESP32_GENERIC-20250415-v1.25.0.bin
|
335
|
-
│ │ ├── boot.py
|
336
|
-
│ │ ├── main.py
|
337
|
-
|
338
|
-
|
339
|
-
│ │ ├── style.css
|
340
|
-
│ │ ├── welcome.html
|
341
|
-
│ │ ├── wifi_updated.html
|
342
|
-
├── setup.py
|
343
|
-
├── README.md
|
344
|
-
|
384
|
+
│ │ ├── boot.py # Minimal boot script
|
385
|
+
│ │ ├── main.py # Imports and runs your app module
|
386
|
+
├── setup.py # Packaging and install configuration
|
387
|
+
├── README.md # Project documentation
|
345
388
|
```
|
346
389
|
|
390
|
+
|
347
391
|
---
|
348
392
|
|
349
393
|
## Troubleshooting
|
@@ -361,3 +405,4 @@ Fork and submit pull requests at [https://github.com/ishanoshada/microweb](https
|
|
361
405
|
|
362
406
|
---
|
363
407
|
|
408
|
+
**Repository Views** 
|
@@ -1,13 +1,15 @@
|
|
1
1
|
microweb/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
microweb/cli.py,sha256=
|
2
|
+
microweb/cli.py,sha256=cUfr14gV9uH-DvZFX3nRqr-RduldxfXn0jBIKWXJ7-k,27560
|
3
3
|
microweb/microweb.py,sha256=WlDV1Fk5M4EsvmmkWKVLWaoZh6Vgl9G0qORFsQEQ3iM,12799
|
4
4
|
microweb/uploader.py,sha256=EGUXscOAQ0gZJKBaRyAr5XzmxCWhabgh-QO3fBE2a38,3097
|
5
5
|
microweb/wifi.py,sha256=S2gOOmTKp2G1uUHxOH0DHQ_k7QSERKHDCm89qv-WlKs,904
|
6
6
|
microweb/firmware/ESP32_GENERIC-20250415-v1.25.0.bin,sha256=HrGohHPjKqak1F3BtbatQLwfBhKOeqhUjkOM-kYz2hs,1702240
|
7
|
+
microweb/firmware/ESP8266_GENERIC-20250415-v1.25.0.bin,sha256=DcEkzHgtDl-BCwap6UbgKhirHjbWepSgd8PonauaVcY,636820
|
7
8
|
microweb/firmware/boot.py,sha256=1522jvxAjGk-y7X4mzMilB4pMQ6KrAgosDXRAMtac8k,22
|
8
9
|
microweb/firmware/main.py,sha256=g_rg-1qpQEzvQoSnhXairx_v7xHNuGDJVrmbdziKt1A,10
|
9
|
-
microweb-0.1.
|
10
|
-
microweb-0.1.
|
11
|
-
microweb-0.1.
|
12
|
-
microweb-0.1.
|
13
|
-
microweb-0.1.
|
10
|
+
microweb-0.1.2.dist-info/licenses/LICENSE,sha256=7tSPQeJFv8168MWaFKTWEqYRvM9Lh5xsBh-US0mxUF0,1070
|
11
|
+
microweb-0.1.2.dist-info/METADATA,sha256=YGuHvapfLWvPQifBTTlXcKEBVvme5gPNzaXPGNsM2LM,13725
|
12
|
+
microweb-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
13
|
+
microweb-0.1.2.dist-info/entry_points.txt,sha256=yBGjIy-e3mx-HHkmkGNLBcSDEALB327du5KuauZHmg4,46
|
14
|
+
microweb-0.1.2.dist-info/top_level.txt,sha256=CkRcDTo-nv4JTieAZPKFC-EGKYYQmKNq5C8zU2k5zRM,9
|
15
|
+
microweb-0.1.2.dist-info/RECORD,,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Ishan Oshada
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
File without changes
|
File without changes
|
File without changes
|