bmi.html
1<!DOCTYPE html> 2<html lang="ja"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>じゃんけん何出す?</title> 6 <link rel="stylesheet" href="../static/style1.css"> 7 </head> 8 <body> 9 <article> 10 <h1>何を出す?</h1> 11 <h3>あなたの手</h3> 12 <a href="/result/gu"><img src="../static/img/gu.png" alt="グー"></a> 13 <a href="/result/ch"><img src="../static/img/ch.png" alt="チョキ"></a> 14 <a href="/result/pa"><img src="../static/img/pa.png" alt="パー"></a> 15 </form> 16 </article> 17 </body> 18</html>
bmi→resultに行くためのcss.py
1@app.route('/result/<hand>', methods) 2def result(hand): 3 hands=['グー', 'チョキ', 'パー'] 4 shouhai=['あいこ', '負け', '勝ち'] 5 c=randint(0,2) 6 cpu=hands[c] 7 kekka='' 8 my='' 9 if hand=='gu': 10 my=hands[0] 11 if cpu=='グー': 12 kekka=shouhai[0] 13 elif cpu=='チョキ': 14 kekka=shouhai[2] 15 elif cpu=='パー': 16 kekka=shouhai[1] 17 elif hand=='ch': 18 my=hands[1] 19 if cpu=='グー': 20 kekka=shouhai[1] 21 elif cpu=='チョキ': 22 kekka=shouhai[0] 23 elif cpu=='パー': 24 kekka=shouhai[2] 25 elif hand=='pa': 26 my=hands[2] 27 if cpu=='グー': 28 kekka=shouhai[2] 29 elif cpu=='チョキ': 30 kekka=shouhai[1] 31 elif cpu=='パー': 32 kekka=shouhai[0] 33 34 return render_template('result.html', my=my, cpu=cpu, kekka=kekka)
result.html
1<!DOCTYPE html> 2<html lang="ja"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>じゃんけん結果</title> 6 <link rel="stylesheet" href ="../static/style2.css"> 7 </head> 8 <body> 9 <ul><h5></h5> 10 結果を見に行くときは↓↓をクリックしてね<br> 11 <a href="./result1.html"><img src="../static/img/upa.png" alt="結果を見る"></a> 12 </h5></ul> 13 <article> 14 <div> 15 <form action="result1" method="post"> 16 <dl> 17 <h1>出した手は・・・</h1> 18 あなたの手:{{ my }} 敵の手:{{ cpu }} 19 20 {% if my=='グー' and cpu=='グー' %} 21 <p><img src="../static/img/gu.png" alt="グー"> VS <img src="../static/img/gu.png" alt="グー"></p> 22 {% elif my=='グー' and cpu=='チョキ' %} 23 <p><img src="../static/img/gu.png" alt="グー"> VS <img src="../static/img/ch.png" alt="チョキ"></p> 24 {% elif my=='グー' and cpu=='パー' %} 25 <p><img src="../static/img/gu.png" alt="グー"> VS <img src="../static/img/pa.png" alt="パー"></p> 26 27 {% elif my=='チョキ' and cpu=='グー' %} 28 <p><img src="../static/img/ch.png" alt="チョキ"> VS <img src="../static/img/gu.png" alt="グー"></p> 29 {% elif my=='チョキ' and cpu=='チョキ' %} 30 <p><img src="../static/img/ch.png" alt="チョキ"> VS <img src="../static/img/ch.png" alt="チョキ"></p> 31 {% elif my=='チョキ' and cpu=='パー' %} 32 <p><img src="../static/img/ch.png" alt="チョキ"> VS <img src="../static/img/pa.png" alt="パー"></p> 33 34 {% elif my=='パー' and cpu=='グー' %} 35 <p><img src="../static/img/pa.png" alt="パー"> VS <img src="../static/img/gu.png" alt="グー"></p> 36 {% elif my=='パー' and cpu=='チョキ' %} 37 <p><img src="../static/img/pa.png" alt="パー"> VS <img src="../static/img/ch.png" alt="チョキ"></p> 38 {% elif my=='パー' and cpu=='パー' %} 39 <p><img src="../static/img/pa.png" alt="パー"> VS <img src="../static/img/pa.png" alt="パー"></p> 40 {% endif %} 41 </dl> 42 </form> 43 </div> 44 </article> 45 </body> 46</html>
result.htmlの勝敗の結果を出した手をは別に表記させたいと思っています。
そこで、getとpostで区別しようと思っているのですが、やり方がわかりません。
postとgetに分けてはみたもののpostしか動かず。どうしたらgetがうごきますか?
また、postとgetの分け方はあっているのでしょうか??
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/02/17 05:04
2022/02/18 07:13