Skip to content

Commit e673ddf

Browse files
author
kangkang
committed
this new
2 parents ea21f8b + 3a979e9 commit e673ddf

File tree

14 files changed

+3273
-71
lines changed

14 files changed

+3273
-71
lines changed

.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 170 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ python案例分享
55
案例二:python unittest使用<br>
66
案例三:python selenium使用<br>
77
案例四:unittest_selenium使用<br>
8+
案例五:python selenium递归<br>
9+
案例六:python cgi项目<br>
10+
11+
12+
813

cgiProject/cgi-bin/index.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
html = """
2+
<html>
3+
<head>
4+
<title>
5+
image
6+
</title>
7+
</head>
8+
<body>
9+
<img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1562231356345&di=14d608194de00e8b04ec741b3b107ab9&imgtype=0&src=http%3A%2F%2Fimage.whhost.net%2Fuploads%2F20180413%2F22%2F1523628708-NofpLxkrHM.jpg">
10+
</body>
11+
</html>
12+
""" #要返回的数据 response 的body
13+
print("content-type:text/html") #返回响应的头部,具体描述的要返回的内容类型,在cgi当中用print进行返回
14+
print("\n") #返回头部结束
15+
print(html) #返回响应的body

cgiProject/cgi-bin/jsonData.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import json
2+
import time
3+
import random
4+
5+
now = time.strftime("%H:%M:%S",time.localtime())
6+
num = random.randint(1,11)
7+
8+
result = {"now":now,"num":num}
9+
10+
josn_result = json.dumps(result) #将字典转换为json
11+
#loads 将json转换为字典
12+
13+
print("content-type:application/json") #返回响应的头部,具体描述的要返回的内容类型,在cgi当中用print进行返回
14+
print("\n") #返回头部结束
15+
print(josn_result) #返回响应的body

cgiProject/image.html

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<html>
2+
<head>
3+
<title>
4+
image
5+
</title>
6+
<script src="js/jquery-3.1.1.min.js"></script>
7+
<script src="js/Chart.min.js"></script>
8+
</head>
9+
<body>
10+
<canvas id="panel" height="330px" width="500px">
11+
12+
</canvas>
13+
<script>
14+
$(
15+
function () {
16+
var can = $("#panel").get(0).getContext("2d");//设置为2d画布
17+
var canData = {
18+
labels:["a","b","c","d","e","f"], //x轴的坐标
19+
datasets:[
20+
{
21+
fillColor: "rgba(255,255,0,0.2)", //线条下的填充色
22+
strokeColor: "rgba(0,255,0,1)", //线条颜色
23+
data:[1,2,3,2,1,5] //y轴对应x轴的数据
24+
}
25+
]
26+
};
27+
var line = new Chart(can).Line(canData);
28+
setInterval(
29+
function () {
30+
$.ajax(
31+
{
32+
type:"get", //ajax请求的类型
33+
url:"/cgi-bin/jsonData.py", //ajax请求的地址
34+
data:"", //请求需要携带的数据
35+
success: function (data) {
36+
line.addData(
37+
[data["num"]],
38+
data["now"]
39+
);
40+
var len = line.datasets[0].points.length; //获取点个数
41+
if(len > 8){
42+
line.removeData()
43+
}
44+
},//回调函数,如果请求成功,ajax自动调用当前函数,将返回结果传递给data
45+
error: function (error) {
46+
console.log(error)
47+
}//回调函数,如果请求失败,ajax自动调用当前函数,将返回错误传递给error
48+
}
49+
)//使用ajax
50+
},1000
51+
)
52+
53+
}
54+
)
55+
</script>
56+
</body>
57+
</html>

cgiProject/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<html>
2+
<head>
3+
<title>
4+
index
5+
</title>
6+
</head>
7+
<body>
8+
<h1>hello world</h1>
9+
</body>
10+
</html>

0 commit comments

Comments
 (0)