result.html
1<!DOCTYPE html> 2<html lang="ja"> 3 <head> 4 <meta charset="UTF-8" http-equiv="Refresh" content="3;URL=kekka.html"> 5 <title>じゃんけん結果</title> 6 <link rel="stylesheet" href ="../static/style2.css"> 7 </head> 8 9 10 <body> 11 <ul><h5> 12 5秒たっても画面が切り替わらい時はうーぱーをタッチしてね<br> 13 <a href="./kekka.html"><img src="../static/img/upa.png" alt="結果を見る"></a> 14 </h5></ul> 15 <article> 16 <h1>出した手は・・・</h1> 17 あなたの手:{{ my }} 敵の手:{{ cpu }} 18 <form action="kekka" method="POST"> 19 {% if my=='グー' and cpu=='グー' %} 20 <p><img src="../static/img/gu.png" alt="グー"> VS <img src="../static/img/gu.png" alt="グー"></p> 21 {% elif my=='グー' and cpu=='チョキ' %} 22 <p><img src="../static/img/gu.png" alt="グー"> VS <img src="../static/img/ch.png" alt="チョキ"></p> 23 {% elif my=='グー' and cpu=='パー' %} 24 <p><img src="../static/img/gu.png" alt="グー"> VS <img src="../static/img/pa.png" alt="パー"></p> 25 26 {% elif my=='チョキ' and cpu=='グー' %} 27 <p><img src="../static/img/ch.png" alt="チョキ"> VS <img src="../static/img/gu.png" alt="グー"></p> 28 {% elif my=='チョキ' and cpu=='チョキ' %} 29 <p><img src="../static/img/ch.png" alt="チョキ"> VS <img src="../static/img/ch.png" alt="チョキ"></p> 30 {% elif my=='チョキ' and cpu=='パー' %} 31 <p><img src="../static/img/ch.png" alt="チョキ"> VS <img src="../static/img/pa.png" alt="パー"></p> 32 33 {% elif my=='パー' and cpu=='グー' %} 34 <p><img src="../static/img/pa.png" alt="パー"> VS <img src="../static/img/gu.png" alt="グー"></p> 35 {% elif my=='パー' and cpu=='チョキ' %} 36 <p><img src="../static/img/pa.png" alt="パー"> VS <img src="../static/img/ch.png" alt="チョキ"></p> 37 {% elif my=='パー' and cpu=='パー' %} 38 <p><img src="../static/img/pa.png" alt="パー"> VS <img src="../static/img/pa.png" alt="パー"></p> 39 {% endif %} 40 </form> 41 </article> 42 </body> 43</html>
app.py
1@app.route('/result/<hand>') 2def result(hand): 3 hands=['グー', 'チョキ', 'パー'] 4 c=randint(0,2) 5 cpu=hands[c] 6 if hand=='gu' or hand=='ch' or hand=='pa': 7 session.permanent=True 8 session['hand']=hand 9 my='' 10 if hand=='gu': 11 my=hands[0] 12 elif hand=='ch': 13 my=hands[1] 14 elif hand=='pa': 15 my=hands[2] 16 return render_template('result.html', my=my, cpu=cpu) 17 18@app.route('/kekka') 19def kekka(): 20 myhand=session['hand'] 21 22 return render_template('kekka.html', myhand=myhand)
↑一部のみをはっています。
result.htmlのmetaで、http-equiv="Refresh" content="3;URL=kekka.html"で、3秒後に自動で飛ぶようにしているのですが、同じファイル・同じ高さにあるhtmlに飛ぼうとしたら↓のエラーが出てしまいます。
TypeError: The view function for 'result' did not return a valid response. The function either returned None or ended without a return statement.
何が原因なのでしょうか?
どこでひっかかっているのかがわからず・・。
教えていただけますとありがたいです。

回答1件
あなたの回答
tips
プレビュー