Just if you want a Micro HTTP Web Server and language templating for MicroPython (used on Pycom modules) :
https://github.com/jczic/MicroWebSrv

Your library looks great! Is it compatible with an ESP32? Have you tried implementing websockets?jczic wrote:Hello,
Just if you want a Micro HTTP Web Server and language templating for MicroPython (used on Pycom modules) :
https://github.com/jczic/MicroWebSrv
with this codeAttributeError: 'MicroWebSrv' object has no attribute 'SendText'
Code: Select all
from microWebSrv import MicroWebSrv
import time
def _acceptWebSocketCallback(webSocket, httpClient) :
print("WS ACCEPT")
webSocket.RecvTextCallback = _recvTextCallback
webSocket.RecvBinaryCallback = _recvBinaryCallback
webSocket.ClosedCallback = _closedCallback
def _recvTextCallback(webSocket, msg) :
print("WS RECV TEXT : %s" % msg)
webSocket.SendText("Reply for %s" % msg)
def _recvBinaryCallback(webSocket, data) :
print("WS RECV DATA : %s" % data)
def _closedCallback(webSocket) :
print("WS CLOSED")
mws = MicroWebSrv() # TCP port 80 and files in /flash/www
mws.MaxWebSocketRecvLen = 256 # Default is set to 1024
mws.WebSocketThreaded = False # WebSockets without new threads
mws.AcceptWebSocketCallback = _acceptWebSocketCallback# Function to receive WebSockets
mws.Start()
t=0
while True:
print(t)
mws.SendText(str(t))
time.sleep(1)
t+=1
Code: Select all
from microWebSrv import MicroWebSrv
import utime
wsflag = False
def _acceptWebSocketCallback(webSocket, httpClient) :
print("WS ACCEPT")
webSocket.RecvTextCallback = _recvTextCallback
webSocket.RecvBinaryCallback = _recvBinaryCallback
webSocket.ClosedCallback = _closedCallback
def _recvTextCallback(webSocket, msg) :
print("WS RECV TEXT : %s" % msg)
webSocket.SendText("Reply for %s" % msg+ str(t))
global wsflag
global ws
ws = webSocket
wsflag = True
def _recvBinaryCallback(webSocket, data) :
print("WS RECV DATA : %s" % data)
def _closedCallback(webSocket) :
print("WS CLOSED")
mws = MicroWebSrv() # TCP port 80 and files in /flash/www
mws.MaxWebSocketRecvLen = 256 # Default is set to 1024
mws.WebSocketThreaded = False # WebSockets without new threads
mws.AcceptWebSocketCallback = _acceptWebSocketCallback# Function to receive WebSockets
mws.Start()
t=0
while not wsflag : pass
while True:
print(t)
if not ws.IsClosed() : ws.SendText(str(t))
utime.sleep_ms(100)
t+=1