πŸ€–Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    TypeError: 'str' object isn't callable

    UIFlow
    1
    1
    1.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ajb2k3A
      ajb2k3
      last edited by

      I need help with my web page hosting code.
      Can someone point out what I'm missing?
      from m5stack import *
      from m5ui import *
      from uiflow import *
      import network

      setScreenColor(0x111111)

      label0 = M5TextBox(0, 62, "label0", lcd.FONT_Default, 0xFFFFFF, rotate=0)
      label1 = M5TextBox(0, 89, "label1", lcd.FONT_Default, 0xFFFFFF, rotate=0)

      import gc
      wlan = network.WLAN(network.AP_IF)
      wlan.active(True)
      wlan.config(essid='ESP_test', password='123456')
      if (wlan.isconnected()) == False:
        label0.setText('No connection to Access Point')
      else:
        label0.setText('Connected to Access Point')
      label1.setText(str(wlan.ifconfig()))
      #False resaults when run and not downloaded.
      
      html_page = '''<!DOCTYPE HTML>
      			<html>
      			<head>
      				<meta name=β€œViewport” content=β€œwidth=device-width, initial-scale=1”
      				</head>
      			<body>
      				<center><h1>Yun Cloud Sensor Suite. </h1></center>
      				<center><p>Temperature is <strong>””” + str(t) + β€œβ€β€ C.</strong>.</p></center>
      				<center><p>Pressure is <strong>””” + str(p) + β€œβ€β€ Pascal.</strong>.</p></center>
      				<center><p>Humidity is <strong>””” + str(h) + β€œβ€β€ Percent.</strong>.</p></center>
      			</body>
      			</html>
      '''
      html_page
      import socket
      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      s.bind(('', 80))
      s.listen(5)
      gc.collect()
      conn, addr = s.accept()
      print('Got a connection from %s' % str(addr))
      request = conn.recv(1024)
      request = str(request)
      print('Content = %s' % request)
      response = html_page()
      conn.send('HTTP/1.1 200 OK\n')
      conn.send('Content-Type: text/html\n')
      conn.send('Connection: close\n\n')
      conn.sendall(response)
      Conn.close()
      while True:
        wait_ms(2)
      

      Error is as follows

      '<!DOCTYPE HTML>\n\t\t\t<html>\n\t\t\t<head>\n\t\t\t\t<meta name=\u201cViewport\u201d content=\u201cwidth=device-width, initial-scale=1\u201d\n\t\t\t\t</head>\n\t\t\t<body>\n\t\t\t\t<center><h1>Yun Cloud Sensor Suite. </h1></center>\n\t\t\t\t<center><p>Temperature is <strong>\u201d\u201d\u201d + str(t) + \u201c\u201d\u201d C.</strong>.</p></center>\n\t\t\t\t<center><p>Pressure is <strong>\u201d\u201d\u201d + str(p) + \u201c\u201d\u201d Pascal.</strong>.</p></center>\n\t\t\t\t<center><p>Humidity is <strong>\u201d\u201d\u201d + str(h) + \u201c\u201d\u201d Percent.</strong>.</p></center>\n\t\t\t</body>\n\t\t\t</html>\n'
      Got a connection from ('192.168.4.2', 49311)
      Content = b'GET / HTTP/1.1\r\nHost: 192.168.4.1\r\nConnection: keep-alive\r\nCache-Control: max-age=0\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\r\nAccept-Encoding: gzip, deflate\r\nAccept-Language: en-GB,en-US;q=0.9,en;q=0.8\r\n\r\n'
      Traceback (most recent call last):
        File "<stdin>", line 42, in <module>
      TypeError: 'str' object isn't callable
      >>> 
      >>> 
      >>> 
      

      UIFlow, so easy an adult can learn it!
      If I don't know it, be patient!
      I've ether not learned it or am too drunk to remember it!
      Author of the WIP UIFlow Handbook!
      M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

      1 Reply Last reply Reply Quote 0
      • First post
        Last post