TypeError: 'str' object isn't callable
-
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 networksetScreenColor(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 >>> >>> >>>
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register Login