質問編集履歴
5
ファイルの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,58 +2,8 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
↓ cgiファイル
|
5
|
-
|
6
|
-
#!/home/azusa/anaconda3/bin/python
|
7
|
-
import cgi
|
8
|
-
import csv
|
9
|
-
import numpy as np
|
10
|
-
import cv2
|
11
|
-
|
12
|
-
#catch
|
13
|
-
form = cgi.FieldStorage()
|
14
|
-
pos_x = form.getfirst('pos_x')
|
15
|
-
num = form.getfirst('file_name')
|
16
|
-
|
17
|
-
#list
|
18
|
-
pos_x = str(pos_x)
|
19
|
-
pos_x_list = pos_x.split(',')
|
20
|
-
|
21
|
-
##out
|
22
|
-
|
5
|
+
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-11-09/e9131007-cddb-4bf0-80af-a02cfa817de7.png)
|
23
|
-
|
24
|
-
f.write(pos_x)
|
25
|
-
f.close()
|
26
|
-
|
27
|
-
l = [int(num)]
|
28
|
-
for i in range(len(pos_x_list)):
|
29
|
-
if i > 64:
|
30
|
-
break
|
31
|
-
elif i+1 >= len(pos_x_list):
|
32
|
-
break
|
33
|
-
l.append(pos_x_list[i+1])
|
34
|
-
|
35
|
-
|
6
|
+
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-11-09/41e89bb3-ff77-4f8d-9c2f-c0b5636c4692.png)
|
36
|
-
writer = csv.writer(f)
|
37
|
-
writer.writerow(l)
|
38
|
-
|
39
|
-
##html
|
40
|
-
print("Content-Type: text/html\n")
|
41
|
-
htmlText = '''
|
42
|
-
<!DOCTYPE html>
|
43
|
-
<html lang="ja">
|
44
|
-
<head>
|
45
|
-
<meta charset="utf-8">
|
46
|
-
<title>Position Recorded</title>
|
47
|
-
</head>
|
48
|
-
<BODY onLoad=setTimeout("location.href='trail2X.html'",100)>
|
49
|
-
<body>
|
50
|
-
<p>x: %s</p>
|
51
|
-
<p>file_name: %s</p>
|
52
|
-
</body>
|
53
|
-
</html>
|
54
|
-
'''%(pos_x, num)
|
55
|
-
print(htmlText.encode("utf-8", 'ignore').decode('utf-8'))
|
56
|
-
|
57
7
|
|
58
8
|
↓htmlファイル
|
59
9
|
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-11-09/5984fbd0-f73f-4f10-96f3-bb5d644238de.png)
|
4
htmlファイルの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -55,52 +55,8 @@
|
|
55
55
|
print(htmlText.encode("utf-8", 'ignore').decode('utf-8'))
|
56
56
|
|
57
57
|
|
58
|
-
|
59
58
|
↓htmlファイル
|
60
|
-
<!DOCTYPE html>
|
61
|
-
<html lang="ja">
|
62
|
-
<head>
|
63
|
-
<meta charset="utf-8">
|
64
|
-
<title>マウス座標取得</title>
|
65
|
-
</head>
|
66
|
-
|
67
|
-
<body>
|
68
|
-
<script>
|
69
|
-
window.onload = function(){
|
70
|
-
var isWriting = false;
|
71
|
-
document.body.addEventListener("mousedown", function(e){
|
72
|
-
isWriting = true;
|
73
|
-
});
|
74
|
-
document.body.addEventListener("mouseup", function(e){
|
75
|
-
isWriting = false;
|
76
|
-
});
|
77
|
-
document.getElementById("canvas").addEventListener("mousemove", function(e){
|
78
|
-
if(isWriting == true) {
|
79
|
-
document.getElementById("screen_x").innerText = e.screenX;
|
80
|
-
document.getElementById("screen_y").innerText = e.screenY;
|
81
|
-
document.getElementsByName("pos_x")[0].value = document.getElementsByName("pos_x")[0].value + "," + e.offsetX;
|
82
|
-
document.getElementsByName("pos_y")[0].value = document.getElementsByName("pos_y")[0].value + "," + e.offsetY;
|
83
|
-
|
84
|
-
var context = document.getElementById("canvas").getContext("2d");
|
85
|
-
context.beginPath();
|
86
|
-
context.arc(e.offsetX, e.offsetY, 5, 0, Math.PI * 2, false);
|
87
|
-
context.fillStyle = "black";
|
88
|
-
context.fill();
|
89
|
-
|
90
|
-
}
|
91
|
-
});
|
92
|
-
}
|
93
|
-
</script>
|
94
|
-
<canvas id="canvas" width="256" height="256" style="background-color: yellow"></canvas>
|
95
|
-
|
59
|
+
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-11-09/5984fbd0-f73f-4f10-96f3-bb5d644238de.png)
|
96
|
-
<form action="./trail2x.cgi" method="post">
|
97
|
-
<input type="hidden" name="pos_x" value="0">
|
98
|
-
<input type="hidden" name="pos_y" value="0">
|
99
|
-
<p>Please input file name<br><input type="text" name="file_name"></p><br>
|
100
|
-
<input type="submit" name="submit" value="送信">
|
101
|
-
</form>
|
102
|
-
</body>
|
103
|
-
</html>
|
104
60
|
|
105
61
|
|
106
62
|
|
3
htmlファイルの更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -57,7 +57,8 @@
|
|
57
57
|
|
58
58
|
|
59
59
|
↓htmlファイル
|
60
|
-
|
60
|
+
<!DOCTYPE html>
|
61
|
+
<html lang="ja">
|
61
62
|
<head>
|
62
63
|
<meta charset="utf-8">
|
63
64
|
<title>マウス座標取得</title>
|
@@ -101,3 +102,5 @@
|
|
101
102
|
</body>
|
102
103
|
</html>
|
103
104
|
|
105
|
+
|
106
|
+
|
2
htmlファイルの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,8 +58,6 @@
|
|
58
58
|
|
59
59
|
↓htmlファイル
|
60
60
|
|
61
|
-
<!DOCTYPE html>
|
62
|
-
<html lang="ja">
|
63
61
|
<head>
|
64
62
|
<meta charset="utf-8">
|
65
63
|
<title>マウス座標取得</title>
|
1
htmlファイルのコード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,8 +56,6 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
-
|
60
|
-
|
61
59
|
↓htmlファイル
|
62
60
|
|
63
61
|
<!DOCTYPE html>
|
@@ -105,4 +103,3 @@
|
|
105
103
|
</body>
|
106
104
|
</html>
|
107
105
|
|
108
|
-
|