Tags:
tag this topic
create new tag
view all tags
---+ The microdot web server framework In contrast to _picoweb_, _microdot_ supplies extensive [[https://microdot.readthedocs.io/en/latest/][documentation]]. It is a good idea to read this documentation carefully and compare it with the example programs provided. You can download the microdot repository from github: https://github.com/miguelgrinberg/microdot.<br />In order to run the examples using the modules included in your !MicroPython interpreter, you must make some minor changes to them: * when importing microdot please replace * from _microdot import Microdot_ by <i>from microdot.microdot import Microdot <br /></i>The same is true for the other modules (microdot_asyncio, microdot_ssl, microdot websockets ...) * You should connect to your !WiFi network, before starting the server: * from wifi_connect import connect, getIPAddress * connect(ssid="yourSSID",password="yourPassword") * Please start the server with * app.run(debug=True,host=getIPAddress,port=80) # debug=True is optional, host defines the IP address of your server, port 80 is the standard HTTP port * You may add the following print statement before app.run, which will produce a link allowing you to easily start the WEB browser with the correct server address: * print("Starting WEB server on !http://" + getIPAddress()) ---++ The microdot exercises You can implement the same programs as shown on the [[WEB Server Picoweb]] page also with microdot. While picoweb does not provide support for web sockets, microdot does. Please git it a try, starting off with the examples provided in the github repository. The exercise sheet ([[A WEB server]]) is now based on microdot. ---++ Server side events on microdot microdot does not support server side events out of the box. When using server side events, your web server should first send: <verbatim>"HTTP/1.0 200 OK\r\n" "Content-Type: text/event-stream\r\n" "\r\n"</verbatim> before sending a stream of information. I added a method send_evt_src_header() to the Microdot class, which does exactly this. After calling send_evt_src_header() you may return an iterator, which will repeatedly send information to the client (see the Fibonacci example in the documentation). -- %USERSIG{UliRaich - 2022-11-12}% ---++ Comments %COMMENT%
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r2
<
r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r2 - 2022-11-16
-
UliRaich
Home
Site map
AFNOG web
Embedded_Systems web
IoT_Course_English web
IoT_Course_French web
Main web
Sandbox web
TWiki web
IoT_Course_English Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback