---+ 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%
This topic: IoT_Course_English
>
WebHome
>
InternetAccess
>
WEBServer
>
WebServerMicrodot
Topic revision: r2 - 2022-11-16 - UliRaich
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