开心的兔子 发表于 2023-10-7 18:22:45

掌控板支持的图片类型

本帖最后由 开心的兔子 于 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>&nbsp; &nbsp; client_connection, client_address = socket.accept()</blockquote><blockquote>&nbsp; &nbsp; request = client_connection.recv(1024)</blockquote><blockquote>&nbsp; &nbsp; print(request.decode("utf-8"))</blockquote><blockquote>&nbsp; &nbsp; #暂时不知道是干嘛的</blockquote><blockquote>&nbsp; &nbsp; http_response = """\</blockquote><blockquote>HTTP/1.1 200 OK</blockquote><blockquote><br></blockquote><blockquote>&lt;!DOCTYPE html&gt;</blockquote><blockquote>&lt;html lang="zh-CN"&gt;</blockquote><blockquote>&lt;head&gt;</blockquote><blockquote>&nbsp; &nbsp; &lt;meta charset="UTF-8"&gt;</blockquote><blockquote>&nbsp; &nbsp; &lt;title&gt;不欢迎你&lt;/title&gt;</blockquote><blockquote>&nbsp; &nbsp; &lt;style&gt;</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; body {</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; display: flex;</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; justify-content: center;</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; align-items: center;</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height: 100vh;</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padding: 0;</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin: 0</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; }</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; h1 {</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; font-size: 32px;</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text-align: center;</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; }</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; p {</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; font-size: 24px;</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text-align: center;</blockquote><blockquote>&nbsp; &nbsp; &nbsp; &nbsp; }</blockquote><blockquote>&nbsp; &nbsp; &lt;/style&gt;</blockquote><blockquote>&lt;/head&gt;</blockquote><blockquote>&lt;body&gt;</blockquote><blockquote>&nbsp; &nbsp; &lt;img src="IllustrationBlur42.png"&gt;</blockquote><blockquote>&lt;/body&gt;</blockquote><blockquote>&lt;/html&gt;</blockquote><blockquote>"""</blockquote><blockquote>&nbsp; &nbsp; #上面这段都是网页代码</blockquote><blockquote>&nbsp; &nbsp; client_connection.sendall(http_response.encode("utf-8"))</blockquote><blockquote>&nbsp; &nbsp; client_connection.close()</blockquote><blockquote>&nbsp; &nbsp; #这个我不知道是干啥的</blockquote></blockquote></div><br>
页: [1]
查看完整版本: 掌控板支持的图片类型