bmi.html
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>じゃんけん何出す?</title> <link rel="stylesheet" href="../static/style1.css"> </head> <body> <article> <h1>何を出す?</h1> <h3>あなたの手</h3> <a href="/result/gu"><img src="../static/img/gu.png" alt="グー"></a> <a href="/result/ch"><img src="../static/img/ch.png" alt="チョキ"></a> <a href="/result/pa"><img src="../static/img/pa.png" alt="パー"></a> </form> </article> </body> </html>
bmi→resultに行くためのcss.py
@app.route('/result/<hand>', methods) def result(hand): hands=['グー', 'チョキ', 'パー'] shouhai=['あいこ', '負け', '勝ち'] c=randint(0,2) cpu=hands[c] kekka='' my='' if hand=='gu': my=hands[0] if cpu=='グー': kekka=shouhai[0] elif cpu=='チョキ': kekka=shouhai[2] elif cpu=='パー': kekka=shouhai[1] elif hand=='ch': my=hands[1] if cpu=='グー': kekka=shouhai[1] elif cpu=='チョキ': kekka=shouhai[0] elif cpu=='パー': kekka=shouhai[2] elif hand=='pa': my=hands[2] if cpu=='グー': kekka=shouhai[2] elif cpu=='チョキ': kekka=shouhai[1] elif cpu=='パー': kekka=shouhai[0] return render_template('result.html', my=my, cpu=cpu, kekka=kekka)
result.html
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>じゃんけん結果</title> <link rel="stylesheet" href ="../static/style2.css"> </head> <body> <ul><h5></h5> 結果を見に行くときは↓↓をクリックしてね<br> <a href="./result1.html"><img src="../static/img/upa.png" alt="結果を見る"></a> </h5></ul> <article> <div> <form action="result1" method="post"> <dl> <h1>出した手は・・・</h1> あなたの手:{{ my }} 敵の手:{{ cpu }} {% if my=='グー' and cpu=='グー' %} <p><img src="../static/img/gu.png" alt="グー"> VS <img src="../static/img/gu.png" alt="グー"></p> {% elif my=='グー' and cpu=='チョキ' %} <p><img src="../static/img/gu.png" alt="グー"> VS <img src="../static/img/ch.png" alt="チョキ"></p> {% elif my=='グー' and cpu=='パー' %} <p><img src="../static/img/gu.png" alt="グー"> VS <img src="../static/img/pa.png" alt="パー"></p> {% elif my=='チョキ' and cpu=='グー' %} <p><img src="../static/img/ch.png" alt="チョキ"> VS <img src="../static/img/gu.png" alt="グー"></p> {% elif my=='チョキ' and cpu=='チョキ' %} <p><img src="../static/img/ch.png" alt="チョキ"> VS <img src="../static/img/ch.png" alt="チョキ"></p> {% elif my=='チョキ' and cpu=='パー' %} <p><img src="../static/img/ch.png" alt="チョキ"> VS <img src="../static/img/pa.png" alt="パー"></p> {% elif my=='パー' and cpu=='グー' %} <p><img src="../static/img/pa.png" alt="パー"> VS <img src="../static/img/gu.png" alt="グー"></p> {% elif my=='パー' and cpu=='チョキ' %} <p><img src="../static/img/pa.png" alt="パー"> VS <img src="../static/img/ch.png" alt="チョキ"></p> {% elif my=='パー' and cpu=='パー' %} <p><img src="../static/img/pa.png" alt="パー"> VS <img src="../static/img/pa.png" alt="パー"></p> {% endif %} </dl> </form> </div> </article> </body> </html>
result.htmlの勝敗の結果を出した手をは別に表記させたいと思っています。
そこで、getとpostで区別しようと思っているのですが、やり方がわかりません。
postとgetに分けてはみたもののpostしか動かず。どうしたらgetがうごきますか?
また、postとgetの分け方はあっているのでしょうか??
まだ回答がついていません
会員登録して回答してみよう