Page 1 of 1

MicroWebSrv2 on M5atom lite (ESP32)

Posted: Thu Dec 17, 2020 8:40 pm
by Erik
I'm trying to install the MicroWebSrv2 https://github.com/jczic/MicroWebSrv2 after having tried successfully the first version
on a M5atom lite https://docs.m5stack.com/#/en/core/atom_lite

If anyone has done this before, I'd be glad for every hint. Here's what I have done so far:

I copied the file structure (Solution 3 in the instructions) and added the setup.py to the main,py

The web server starts, but runs into a traceback claiming missing MicroWebSrv2/mods/WebSockets.py which is there:

Code: Select all

Connection successful
('192.168.1.46', '255.255.255.0', '192.168.1.1', '192.168.1.1')
running on M5atom lite

   ---------------------------
   - Python pkg MicroWebSrv2 -
   -      version 2.0.6      -
   -     by JC`zic & HC2     -
   ---------------------------

I (6206) modsocket: Initializing

    [@WebRoute] GET /test-redir
    [@WebRoute] GET /test-post (TestPost1/2)
    [@WebRoute] POST /test-post (TestPost2/2)

Traceback (most recent call last):
File "main.py", line 153, in <module>
File "MicroWebSrv2/microWebSrv2.py", line 136, in LoadModule
MicroWebSrv2Exception: Cannot load module "WebSockets".
MicroPython v1.13 on 2020-09-02; TinyPICO with ESP32-PICO-D4
Type "help()" for more information.
>>>
this is raised by this code in MicroWebSrv2/microWebSrv2.py:

Code: Select all

# ------------------------------------------------------------------------

@staticmethod
def LoadModule(modName) :
    if not isinstance(modName, str) or len(modName) == 0 :
        raise ValueError('"modName" must be a not empty string.')
    if modName in MicroWebSrv2._modules :
        raise MicroWebSrv2Exception('Module "%s" is already loaded.' % modName)
    try :
        modPath  = MicroWebSrv2.__module__.split('microWebSrv2')[0] \
                 + ('mods.%s' % modName)
        module   = getattr(__import__(modPath).mods, modName)
        modClass = getattr(module, modName)
        if type(modClass) is not type :
            raise Exception
        modInstance = modClass()
        MicroWebSrv2._modules[modName] = modInstance
        return modInstance
    except :
        raise MicroWebSrv2Exception('Cannot load module "%s".' % modName)
Here is the file structure on the M5atom lite, I had to copy

Code: Select all

XAsyncSockets.py
twice,.
Funny that it shows two times when made this listing with

Code: Select all

ampy --port /dev/ttyUSB0 ls -r

However, a first exeption concerning

Code: Select all

XAsyncSockets.py
has dissappeared since.

Code: Select all

/ConnectWiFi.py
/MicroWebSrv2/init.py
/MicroWebSrv2/httpRequest.py
/MicroWebSrv2/httpResponse.py
/MicroWebSrv2/libs/XAsyncSockets.py
/MicroWebSrv2/libs/XAsyncSocktes.py
/MicroWebSrv2/libs/urlUtils.py
/MicroWebSrv2/microWebSrv2.py
/MicroWebSrv2/mods/PyhtmlTemplate.py
/MicroWebSrv2/mods/WebSockets.py
/MicroWebSrv2/webRoute.py
/SSL-Cert/openhc2.crt
/SSL-Cert/openhc2.key
/boot.py
/img/microWebSrv2.png
/lib/urequests.py
/main.py
/www/favicon.ico
/www/index.html
/www/pdf.png
/www/style.css
/www/test.pyhtml
/www/wschat.html
/www/wstest.html

Re: MicroWebSrv2 on M5atom lite (ESP32)

Posted: Wed Jan 06, 2021 5:17 am
by marcidy
I had to compile it in as a frozen module to get it to work. Not sure that will address your exact issue. Sorry I can't help further, I didn't use it beyond a bit of exploring. Ended up going the asyncio route.