Python服务器(web配网)

写了个python服务器,其实主要是用来web配网的。

import socket
import sys
import re

SEND_BUF_SIZE = 256
RECV_BUF_SIZE = 256
def start_tcp_server(ip, port):
    html_match = r'(.{0,30})(\w{4})\=(\w{0,16})\&(\w{8})\=(\w{0,30})' #r'(.{0,30})(\w{4})\=(\w{0,16})\&(\w{8})\=(\w{8,20})
    response = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>感谢使用</title></head><body><h1>已收到账号密码,正在自动连接网络,请稍等</h1></body></html>'
    html='<!DOCTYPE html><html><head><!--<meta http-equiv="Content-Type"content="text/html; charset=utf8"/>--><meta http-equiv="Content-Type"content="text/html; charset=utf8"Cache-Control="no-cache"><meta name="viewport"content="width=device-width, initial-scale=1.0"><title>欢迎使用网页配网</title></head><body><form action="wifi"method="get"name=my>WiFi名称:<input type="text"name="ssid"placeholder="请输入您WiFi的名称"id="a"><br>WiFi密码:<input type="text"name="password"placeholder="请输入您WiFi的密码"id="b"><br><input type="submit"name="button"id="button"value="发送"><input type="button"value="跳过"οnclick="jump()"></form><script language="javascript">function jump(){var ssid=my.ssid.value;var password=b.value;var xmlhttp=new XMLHttpRequest();xmlhttp.open("GET","/jump?ssid="+ssid+"&password="+password,true);xmlhttp.send()}</script></body></html>'
    #with open('html_.txt','r',encoding = 'utf-8') as f:
    #    html = f.read()
    # create socket
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_address = (ip
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值