Skip to content

Commit e675b3a

Browse files
committed
add vue demo
1 parent e00cf34 commit e675b3a

29 files changed

Lines changed: 41695 additions & 1 deletion

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,5 @@ dmypy.json
155155

156156
.gitignore
157157
.idea/
158-
.vscode
158+
.vscode
159+
node_modules/

demo/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
存放乱七八糟的代码片段,按需自取。

demo/linux_command_demo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import subprocess
2+
3+
4+
def exec_cmd(cmd, interact=False):...

demo/request_demo.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import http.client
2+
import json
3+
4+
conn = http.client.HTTPConnection("127.0.0.1", 9000)
5+
payload = json.dumps({
6+
"library": "netmiko",
7+
"connection_args": {
8+
"device_type": "hp_comware",
9+
"host": "192.168.56.21",
10+
"username": "netdevops",
11+
"password": "NetDevops@01"
12+
},
13+
"command": "dis version",
14+
"args": {
15+
"use_textfsm": False
16+
},
17+
"queue_strategy": "pinned"
18+
})
19+
headers = {
20+
'x-api-key': '2a84465a-cf38-46b2-9d86-b84Q7d57f288',
21+
'Content-Type': 'application/json'
22+
}
23+
# conn.request("POST", "/getconfig", payload, headers)
24+
# res = conn.getresponse()
25+
# data = res.read()
26+
# print(data.decode("utf-8"))
27+
28+
payload = ''
29+
conn.request("GET", "/task/c24651ea-d4f6-43af-8d42-74918648a1d0", payload, headers)
30+
res = conn.getresponse()
31+
data = res.read()
32+
print(data.decode("utf-8"))
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<script type="text/javascript" src="../js/vue.js"></script>
8+
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
9+
<title>Document</title>
10+
</head>
11+
12+
<body>
13+
<div id="root">
14+
Address:
15+
{{ info.address }}
16+
<a :href="info.url">{{info.name}}</a>
17+
</div>
18+
</body>
19+
20+
<script type="text/javascript">
21+
const vm = new Vue({
22+
el: '#root',
23+
// 定义一个 info 属性,让前台可以调用
24+
data: {info: ''},
25+
// mounted 是 vue 生命周期中的其中一步(类比:django 请求的生命周期中可以用中间件做点事情)
26+
mounted(){
27+
// 请求内容,赋值给 vue 对象中的 info 属性,把原来的空字符替换为实际的值
28+
axios.get("./data.json").then(res=>(this.info=res.data))
29+
}
30+
})
31+
32+
</script>
33+
34+
</html>

demo/vue_demo/axios_demo/data.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name":"axios",
3+
"url": "https://axios-http.com/",
4+
"page": "1",
5+
"address": {
6+
"city":"北京",
7+
"country": "中国"
8+
}
9+
}

0 commit comments

Comments
 (0)