2017-06-12 15 views
-1

我想運行這個燒瓶項目,把它不工作。有誰知道爲什麼?與HTML的燒瓶項目不起作用

的.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

燒瓶將在「模板」目錄中查看模板。將你的html模板移動到模板目錄中。它應該工作

+0

謝謝! :)工作! – lakeviking