2017-06-12 8 views
-1

私はこのFlaskプロジェクトを実行しようとしていますが、動作していません。なぜ誰が知っていますか?HTMLのFlaskプロジェクトが動作していません

の.pyファイル:

from flask import Flask, render_template 

app = Flask(__name__) 


@app.route("/") 
def hoofdpagina(): 
    return render_template("afvink2.html") 


if __name__ == '__main__': 
    app.run() 

HTMLファイル:

<!DOCTYPE html> 
<html> 
<body onunload="Reset()" style="background-color:Pink;"> 
<head> 
       <title>Messenger </title> 
     </head> 

     <h3>Messenger</h3> 
Messagebox:<br> <textarea id="chatbox" cols="50" rows="5"></textarea> <br><br> 
<br><input type="text" id="P1" value="ADI" ><input type="text" id="first"><button onclick="B1Function()">Send</button><br><br> 
<br><input type="text" id="P2" value="JS" > <input type="text" id="second"><button onclick="B2Function()">Send</button> 


<script> 
function B1Function() { 
    document.getElementById("chatbox").value += document.getElementById("P1").value ; 
    document.getElementById("chatbox").value += ": " ; 
    document.getElementById("chatbox").value += document.getElementById("first").value ; 
    document.getElementById("chatbox").value += "\r" 
    document.getElementById("first").value = "" 

} 
function B2Function() { 

    document.getElementById("chatbox").value += document.getElementById("P2").value ; 
    document.getElementById("chatbox").value += ": " ; 
    document.getElementById("chatbox").value += document.getElementById("second").value ; 
    document.getElementById("chatbox").value += "\r" 
    document.getElementById("second").value = "" 

} 
function Reset() { 
    document.getElementById("Berichtenbox").value = "" 
    document.getElementById("first").value = "" 
    document.getElementById("second").value = "" 

} 
</script> 

</body> 
</html> 

エラー:

C:\...\...\...\ 
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) 
127.0.0.1 - - [12/Jun/2017 12:12:07] "GET/HTTP/1.1" 500 - 

ページhttp://127.0.0.1:5000/は言う:

Internal Server Error 

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. 

誰も私がこれをどのように修正できるか知っていますか?ありがとう!

+0

これは唯一のコードですか?これをローカルで実行することができます –

+0

例外が発生した場合にサーバがデバッガを表示するように 'app.run(debug = True)'を試すことができます –

+0

'app.run()'を 'app 'に変更できますか? (debug = True) 'を実行し、エラーメッセージを再投稿してください。 – Tushortz

答えて

1

あなたのプロジェクト構造はこれでなければなりません。デフォルトで

├── app.py 
└── templates 
    └── afvink2.html 

render_template方法はテンプレートディレクトリに見えます。

あなたは、単に設定フラスコが提供するチェックしてくださいフラスコ

app = Flask(__name__, template_folder="views") 
app = Flask(__name__, template_folder="path/to/whatever") 

にパラメータを挙げてビューまたは

公共にテンプレートのディレクトリを設定することができます。 documentationはきれいです。

+0

ありがとう!!働いた:) – lakeviking

+0

それは知っているのは良いです:) –

0

Flaskは "templates"ディレクトリのテンプレートを検索します。 htmlテンプレートをテンプレートディレクトリに移動します。それは動作するはずです

+0

ありがとう! :)働いた! – lakeviking

関連する問題