質問編集履歴
2
内容に誤りがあり、修正しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -35,6 +35,8 @@
|
|
35
35
|
url = f'https://www.humuhumu/{neres}/hogehoge/{snres}/satesate/{nores}/houhou'
|
36
36
|
|
37
37
|
response = requests.get(url, params=param, headers=headers)
|
38
|
+
|
39
|
+
print(response)
|
38
40
|
```
|
39
41
|
|
40
42
|
```d
|
1
変数名、ファイル名等に誤りがあり、一部修正しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,42 +1,50 @@
|
|
1
1
|
Flaskでwebサイトを構築中です。
|
2
2
|
|
3
3
|
1.あるページ(a.html)のフォームに入力し、ボタンで実行
|
4
|
-
2.入力データを変数に格納
|
4
|
+
2.入力データをb.pyで受け取り、変数に格納
|
5
|
-
2.その変数を
|
5
|
+
2.その変数をc.pyに引渡して実行
|
6
|
-
3.実行結果を
|
6
|
+
3.実行結果をd.htmlで出力
|
7
7
|
|
8
8
|
という流れを実現したいと考えています。
|
9
9
|
|
10
10
|
※それぞれ、該当箇所のみ抜粋しています。
|
11
11
|
```a
|
12
|
-
<form action="/
|
12
|
+
<form action="/d" method="POST">
|
13
|
-
<p>ida<input type="text" name="
|
13
|
+
<p>ida<input type="text" name="neid"></p>
|
14
|
-
<p>idb<input type="text" name="
|
14
|
+
<p>idb<input type="text" name="snid"></p>
|
15
|
-
<p>idc<input type="text" name="
|
15
|
+
<p>idc<input type="text" name="noid"></p>
|
16
16
|
<p><button class="oshimasu">button</button></p>
|
17
17
|
</form>
|
18
18
|
```
|
19
19
|
|
20
20
|
```b
|
21
|
-
@app.route('/
|
21
|
+
@app.route('/d', methods=['POST'])
|
22
22
|
def confirm():
|
23
23
|
if request.method == 'POST':
|
24
|
-
|
24
|
+
neres = request.form["neid"]
|
25
|
-
|
25
|
+
snres = request.form["snid"]
|
26
|
-
|
26
|
+
nores = request.form["noid"]
|
27
|
-
proc = subprocess.run(['python','
|
27
|
+
proc = subprocess.run(['python','c.py'], stdout=PIPE, stderr=PIPE, text=True)
|
28
28
|
res = proc.stdout
|
29
|
-
return render_template('
|
29
|
+
return render_template('d.html', response = res)
|
30
30
|
```
|
31
31
|
|
32
32
|
```c
|
33
|
+
import b
|
34
|
+
|
35
|
+
url = f'https://www.humuhumu/{neres}/hogehoge/{snres}/satesate/{nores}/houhou'
|
36
|
+
|
37
|
+
response = requests.get(url, params=param, headers=headers)
|
38
|
+
```
|
39
|
+
|
40
|
+
```d
|
33
41
|
<p>{{ response }}</p>
|
34
42
|
```
|
35
43
|
|
36
|
-
b.pyの「subprocess.run」行を抜き、
|
44
|
+
b.pyの「subprocess.run」行を抜き、d.htmlでそれぞれの変数に格納したデータを表示することは
|
37
45
|
成功しています。
|
38
|
-
また、入力フォームを用意せずにボタンを押すことでsubprocess.runで
|
46
|
+
また、入力フォームを用意せずにボタンを押すことでsubprocess.runでc.pyを実行し、その結果を
|
39
|
-
|
47
|
+
d.htmlに表示することにも成功しています。
|
40
48
|
|
41
49
|
したがって、subprocessに変数を渡せていないものと考えています。煮詰まりました。
|
42
50
|
input等を追加したりしてみたのですが…
|