掌控板支持的图片类型
本帖最后由 开心的兔子 于 2023-10-7 18:24 编辑 <br /><br />前几天逛论坛的时候看到了这样一篇<font style="background-color:initial"><a href="https://mc.dfrobot.com.cn/thread-316908-1-1.html" target="_blank">帖子</a></font>,可以用掌控板做网站服务器<br>本人虽然html不是很好<font style="background-color:white"><font color="#ffffff">(就是不会( </font><font color="#000000">但是我还是想逝世显示图片,不过显示成了这个样子(截图)</font></font><br><font style="background-color:white"><font color="#000000">这就很尴尬了……</font></font><br><font color="#000000">原图也上传了,各位帮我看看呗(</font><br><font color="#000000">下面是使用的代码</font><br><div class="blockcode"><blockquote><blockquote>from mpython import *</blockquote><blockquote><br></blockquote><blockquote>import network</blockquote><blockquote><br></blockquote><blockquote>my_wifi = wifi()</blockquote><blockquote><br></blockquote><blockquote>my_wifi.connectWiFi('CMCC-F2qJ', 'g7qd2ifh')</blockquote><blockquote>#连接Wifi</blockquote><blockquote>import usocket</blockquote><blockquote>#使用Socket</blockquote><blockquote>HOST, PORT = '', 80</blockquote><blockquote>#端口</blockquote><blockquote>socket = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)</blockquote><blockquote>socket.setsockopt(usocket.SOL_SOCKET, usocket.SOCK_STREAM, 1)</blockquote><blockquote>socket.bind((HOST, PORT))</blockquote><blockquote>socket.listen(1)</blockquote><blockquote>#创建Socket参数</blockquote><blockquote>print('Serving HTTP on port %s ...' % PORT)</blockquote><blockquote>oled.DispChar(my_wifi.sta.ifconfig(), 0, (1-1)*16, 1)</blockquote><blockquote>oled.DispChar("服务准备完毕", 0, (2-1)*16, 1)</blockquote><blockquote>oled.DispChar("注意运行时间不要太长", 0, (3-1)*16, 1)</blockquote><blockquote>oled.DispChar("爱惜一点板子哦", 0, (4-1)*16, 1)</blockquote><blockquote>oled.show()</blockquote><blockquote>print(my_wifi.sta.ifconfig())</blockquote><blockquote>#屏幕(串口)显示信息表示正常运行</blockquote><blockquote>while True:</blockquote><blockquote> client_connection, client_address = socket.accept()</blockquote><blockquote> request = client_connection.recv(1024)</blockquote><blockquote> print(request.decode("utf-8"))</blockquote><blockquote> #暂时不知道是干嘛的</blockquote><blockquote> http_response = """\</blockquote><blockquote>HTTP/1.1 200 OK</blockquote><blockquote><br></blockquote><blockquote><!DOCTYPE html></blockquote><blockquote><html lang="zh-CN"></blockquote><blockquote><head></blockquote><blockquote> <meta charset="UTF-8"></blockquote><blockquote> <title>不欢迎你</title></blockquote><blockquote> <style></blockquote><blockquote> body {</blockquote><blockquote> display: flex;</blockquote><blockquote> justify-content: center;</blockquote><blockquote> align-items: center;</blockquote><blockquote> height: 100vh;</blockquote><blockquote> padding: 0;</blockquote><blockquote> margin: 0</blockquote><blockquote> }</blockquote><blockquote> h1 {</blockquote><blockquote> font-size: 32px;</blockquote><blockquote> text-align: center;</blockquote><blockquote> }</blockquote><blockquote> p {</blockquote><blockquote> font-size: 24px;</blockquote><blockquote> text-align: center;</blockquote><blockquote> }</blockquote><blockquote> </style></blockquote><blockquote></head></blockquote><blockquote><body></blockquote><blockquote> <img src="IllustrationBlur42.png"></blockquote><blockquote></body></blockquote><blockquote></html></blockquote><blockquote>"""</blockquote><blockquote> #上面这段都是网页代码</blockquote><blockquote> client_connection.sendall(http_response.encode("utf-8"))</blockquote><blockquote> client_connection.close()</blockquote><blockquote> #这个我不知道是干啥的</blockquote></blockquote></div><br>
页:
[1]