当前位置: 首页 > news >正文

bootstrap3网站模板个人开发app可以上架吗

bootstrap3网站模板,个人开发app可以上架吗,昆明建设网站公司,爱站工具包如何增加网站参考文章:websocket接口自动化集成pytest测试框架 对比需要学习:轮询、长轮询、websocket 三者关系 1、工作中遇到的情况 F12功能看到的数据 2、python中操作ws (1)websocket包 安装 pip install websocket -i https://pyp…

参考文章:websocket接口自动化集成pytest测试框架

对比需要学习:轮询、长轮询、websocket  三者关系 

1、工作中遇到的情况

F12功能看到的数据

 

  

2、python中操作ws

(1)websocket包

安装

pip install websocket -i https://pypi.douban.com/simple/

参考文章:你真的了解WebSocket吗? - 武沛齐 - 博客园

参考视频:08 python fullstack s9day131 websocket原理剖析_哔哩哔哩_bilibili

非常详细,就是照抄学习

(2)flask-websocket

参考文章:Flask教程(十九)SocketIO - 迷途小书童的Note迷途小书童的Note

参考视频:Flask Web开发教程(十九)SocketIO_哔哩哔哩_bilibili

代码:index.html

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>SocketIO Demo</title><script type="text/javascript" src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<!--    <script type="text/javascript" src="//cdn.bootcss.com/socket.io/1.5.1/socket.io.min.js"></script>--><script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/4.5.0/socket.io.js"></script>
</head>
<body><h2>Demo of SocketIO</h2>
<div id="t"></div>
<script>
$(document).ready(function () {namespace = '/dcenter';var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port + namespace);socket.on('dcenter', function (res) {var t = res.data;if (t) {$("#t").append(t).append('<br/>');}});
});
</script>
</body>
</html>

 fw.py

# -*- coding:utf-8 -*-
"""
基于flask开发websocket服务
使用的包是flask-socketio
"""from flask import Flask, render_template
from flask_socketio import SocketIO, emitapp = Flask(__name__)
app.config['SECRET_KEY'] = 'secret_key'socketio = SocketIO()
socketio.init_app(app, cors_allowed_origins='*')name_space = '/dcenter'@app.route('/')
def index():return render_template('index1.html')@app.route('/push')
def push_once():event_name = 'dcenter'broadcasted_data = {'data': "test message!"}socketio.emit(event_name, broadcasted_data, broadcast=False, namespace=name_space)return 'done!'@socketio.on('connect', namespace=name_space)
def connected_msg():print('client connected.')@socketio.on('disconnect', namespace=name_space)
def disconnect_msg():print('client disconnected.')@socketio.on('my_event', namespace=name_space)
def mtest_message(message):print(message)emit('my_response',{'data': message['data'], 'count': 1})if __name__ == '__main__':socketio.run(app, host='127.0.0.1', port=5000, debug=True)

安装

python39 -m pip install --upgrade Flask-SocketIO                升级到了最高版本

python39 -m pip install --upgrade python-socketio==4.6.0   升级到指定版本

python39 -m pip install python-engineio==3.13.2                  安装指定版本

实际操作版本介绍:

eventlet                       0.33.1

python-engineio           4.3.4
python-socketio           5.7.2
Flask                           2.2.2
Flask-SocketIO           5.3.1
Python                        3.9.4

 代码与参考文章一致

重点:!!!!!!!!!!!!!!!!!!!!!!!!

下图问题原因:

The client is using an unsupported version of the Socket.IO or Engine.IO protocols

python - The client is using an unsupported version of the Socket.IO or Engine.IO protocols Error - Stack Overflow

版本不匹配的原因,下面的链接找到的答案:方式就是根据socket.io版本降低,或者升高socket.io的版本

在python-socketio的官网有说明:https://pypi.org/project/python-socketio/

 根据我安装的python-socketio的版本升高js的socket.io版本

//cdnjs.cloudflare.com/ajax/libs/socket.io/4.5.0/socket.io.js

3、ws接口mock

实际使用操作一波

4、ws接口测试

安装

pip install websocket -i https://pypi.douban.com/simple/

pip install websocket-client

clinet.py

# -*- coding:utf-8 -*-class websocketclient:def __init__(self):self.host = 'wss://url'def send(self, params):try:self.ws.send(params)print(f'发送数据成功:{params}')except Exception as e:print(f'发送数据{params}失败')def recv(self):try:res = self.ws.recv()print(f'接收数据成功:{res}')return resexcept Exception as e:print(f'接收数据{res}失败')return ''

imserver_api.py

# -*- coding:utf-8 -*-import websocket
from nomalstudy.client import websocketclientclass ImServerApi(websocketclient):def __init__(self, timeout=5):super(ImServerApi, self).__init__()self.url = f'{self.host}/urgeSocket?_token=6t6OGmrt3xm1SYqDRFrUUeHVhLvHvMVKJQ3UBxaQ4kK9RMde&_appType=receive'self.ws = websocket.create_connection(self.url, timeout=timeout)

test_websocket_api.py

# -*- coding:utf-8 -*-import json
import pytest
from nomalstudy.imserver_api import ImServerApiclass TestImServerApi:kfid = ''  # 定义客服id,全局变量作为各个测试用例的关联数据def setup_class(self):self.im = ImServerApi()  # 创建一个websocket协议的接口对象# 测试客服匹配def test_match(self):params = {"msgId": "111","type": "match","from": "shamo","to": "system"}self.im.send('heartbeat')res = self.im.recv()assert res == 'heartbeat'# res = json.loads(res)  # 将其转换成json对象# assert res['code'] == '0'# 提取msg,msg是匹配到的客服id# self.__class__.kfid = res['msg']# 测试给客服发送正常消息def test_message(self):params = {"msgId": "111","type": "normal","from": "admin","to": f"{self.__class__.kfid}","msg": "你好"}self.im.send(json.dumps(params))res = self.im.recv()res = json.loads(res)  # 将其转换成json对象pytest.assume(res['code'] == '0', f'期望值是0,实际结果是{res["code"]}')pytest.assume(res['msg'] == 'push success', f'期望值是0,实际结果是{res["msg"]}')# 再次接收客服发来的数据res = self.im.recv()res = json.loads(res)  # 将其转换成json对象pytest.assume(res['code'] == '0', f'期望值是0,实际结果是{res["code"]}')pytest.assume(res['msg'] == '同学,你好,非常高兴为你服务,有什么需要我帮忙的呢?', f'期望值是0,实际结果是{res["msg"]}')# 测试发送数据时消息是空的def test_message_msgisnull(self):params = {"msgId": "111","type": "normal","from": "admin","to": f"{self.kfid}","msg": ""}self.im.send(json.dumps(params))res = self.im.recv()res = json.loads(res)  # 将其转换成json对象# 断言系统推送消息时对于消息的判断pytest.assume(res['code'] == '1', f'期望值是1,实际结果是{res["code"]}')pytest.assume(res['msg'] == '消息内容为空', f'期望值是0,实际结果是{res["msg"]}')

http://www.zhongyajixie.com/news/37487.html

相关文章:

  • 长沙建站智能模板注册网站平台
  • 做汇算清缴在哪个网站下网站如何注册
  • 做网站的公司如何运营营销型网站建设多少钱
  • 网站如何做api接口重庆seo排名收费
  • 网站cms分站系统百度引流推广哪家好
  • 外贸网站建设盲区seo排名优化工具推荐
  • 桂林网站建设刷死粉网站推广
  • jsp动态网站开发教程优化大师绿色版
  • 东莞专业网站建设平台友链交换有什么作用
  • 辞职做美食网站沈阳seo公司
  • 网站建设综合推荐微信公众号seo
  • 网站推广和seo网络营销的主要方式
  • 珠海建站联系方式百度正版下载
  • 网站建设奖项专业培训seo的机构
  • 一站式做网站报价百度搜索资源平台token
  • ps网站首页怎么做友好链接
  • 怎么创一个网站企业软文范例
  • 城乡建设网站广告软文200字
  • 请人做网站收费多少钱企业网站推广方案策划
  • 易语言怎么做点击按钮打开网站东莞seo外包平台
  • 基于php mysql的网站开发b站新人视频怎么推广
  • 长沙建网站培训网络推广外包业务怎么样
  • 做么自己做一个网站长沙百度贴吧
  • 深圳市住房和建设局网站百度广告平台电话
  • 淘宝网站怎么做全媒体运营师
  • 可以做网站的电脑软件培训心得简短
  • 建材网站设计seo诊断分析报告
  • 有做网站设计的吗google seo是什么
  • 宝塔软件做网站搜索网站关键词
  • 建设积分商城网站升华网络推广软件