Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5814

MicroPython • Re: How to draw simple chart on client side from server data

$
0
0
I still need your help. As suggested, another var was added. Part of the code for X axis was outcommented...

Code:

<script>  var input = %s;  var labels = %s;  // build the labels on the fly. Could be provided  // from the application here as code uses RTC    //const labels = [];  //for(var i = 0; i < input.length; i ++ ){  //    labels.push(i);  }    const data = {      labels: labels,
then stateis_1 was created and modification on response was done...

Code:

async def serve_client(reader, writer):    global OUT_Buffer_temperature, OUT_Buffer_hours        #print("Client connected")    request_line = await reader.readline()    #print("Request:", request_line)    # We are not interested in HTTP request headers, skip them    while await reader.readline() != b"\r\n":        pass        # find() valid garage-door commands within the request    request = str(request_line)    cmd_up = request.find('DOOR=UP')    cmd_down = request.find('DOOR=DOWN')    cmd_stop = request.find('DOOR=STOP')    stateis = "" # Keeps track of the last command issued    stateis_1 = ""        # Carry out a command if it is found (found at index: 8)    if cmd_stop == 8:        #stateis = ": STOP"        #b = ReadTemperature()        #stateis = (": Temp.garaza = " + str(b) + " *C") #": STOP"        stateis = str(OUT_Buffer_temperature)        stateis_1 = str(OUT_Buffer_hours)        #print(stateis)        #print(stateis_1)        control_door('stop')            elif cmd_up == 8:        stateis = ": ODPRI"        #print(stateis)        control_door('up')            elif cmd_down == 8:        stateis = ": ZAPRI"        #print(stateis)        control_door('down')        response = html % (stateis, stateis_1)    writer.write('HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n')    writer.write(response)    print(response)    await writer.drain()    await writer.wait_closed()
I can run the code without error, but no chart on client side.
Obviously I am doing somethin wrong...

Statistics: Posted by California — Sat Jan 20, 2024 3:19 pm



Viewing all articles
Browse latest Browse all 5814

Trending Articles