本帖最后由 开心的兔子 于 2023-9-27 21:55 编辑
如果上传报错的话可以来试试我这边的代码
- from mpython import *
-
- import network
-
- my_wifi = wifi()
-
- my_wifi.connectWiFi('你的WifI名称', '你的Wifi密码')
-
- import usocket
-
- HOST, PORT = '', 80
-
- socket = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
- socket.setsockopt(usocket.SOL_SOCKET, usocket.SOCK_STREAM, 1)
- socket.bind((HOST, PORT))
- socket.listen(1)
-
- print('Serving HTTP on port %s ...' % PORT)
- while True:
- client_connection, client_address = socket.accept()
- request = client_connection.recv(1024)
- print(request.decode("utf-8"))
-
- http_response = """\
- HTTP/1.1 200 OK
-
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <title>Welcome</title>
- <style>
- body {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100vh;
- padding: 0;
- margin: 0
- }
- h1 {
- font-size: 32px;
- text-align: center;
- }
- p {
- font-size: 24px;
- text-align: center;
- }
- </style>
- </head>
- <body>
- <div>
- <h1>欢迎使用掌控板 HTTP Web 服务器!</h1>
- <p>开始一段愉快的旅程吧!</p>
- <h1>Welcome to mPython HTTP Web Server!</h1>
- <p>Start a pleasant journey!</p>
- <h1>mPython HTTP 웹 서버에 오신 것을 환영합니다!</h1>
- <p>즐거운 여정을 시작하자!</p>
- <h1>mPython HTTP Web サーバへようこそ!</h1>
- <p>楽しい旅の始まり!</p>
- </div>
- </body>
- </html>
- """
- client_connection.sendall(http_response.encode("utf-8"))
- client_connection.close()
复制代码
应该是可以用了
|