1 Star 2 Fork 0

clsld/华软校园内网爬虫

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
sok.py 992 Bytes
一键复制 编辑 原始数据 按行查看 历史
from flask import Flask
from flask_sockets import Sockets
import json
from gevent import pywsgi
from geventwebsocket.handler import WebSocketHandler
app = Flask(__name__)
Sockets = Sockets(app)
sok = {}
@Sockets.route('/test')
def socketResponse(ws):
# send = {}
# send['msg'] = "hello"
# send['faname'] = "钟科杰"
# send['shouname'] = "陈霖"
# send['toid'] = "1111"
# ws.send(json.dumps(send))
while not ws.closed:
re = ws.receive()
if re is not None:
print("收到的信息为:" + re)
id = re.id
if id in sok.keys():
print("此id已存在")
else:
sok.setdefault('id',ws)
else:
print("no receive")
@app.route('/')
def hello():
return 'Hello World! server start!'
if __name__ == "__main__":
server = pywsgi.WSGIServer(('0.0.0.0', 5000), app, handler_class=WebSocketHandler)
print('server start')
server.serve_forever()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/clsld/python_spider.git
[email protected]:clsld/python_spider.git
clsld
python_spider
华软校园内网爬虫
master

搜索帮助