microWebSrv2 on M5atom lite with micropython



  • I'm trying to install the web server microWebSrv2 on a M5atom lite.
    github microWebSrv2

    Has anyone done this before without freezing?
    Would be grateful for any hint.

    I copied the files with ampy to the m5atom lite, here is the file structure on the M5atom lite:

    /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

    And run into this error when booting:

    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:
    # ------------------------------------------------------------------------

    @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)


  • It's probably a typo. I think there should be a / on the line instead of .

    Instead:

     ('mods.%s' % modName)
    

    i think it should be:

    ('mods/%s' % modName)
    

    or

    ('mods\\%s' % modName)