首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >带有HTML的Flask项目不起作用

带有HTML的Flask项目不起作用
EN

Stack Overflow用户
提问于 2017-06-12 18:14:15
回答 1查看 2.1K关注 0票数 -1

我正在尝试运行这个Flask项目,也就是说它不起作用。有人知道为什么吗?

.py文件:

代码语言:javascript
复制
from flask import Flask, render_template

app = Flask(__name__)


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


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

HTML文件:

代码语言:javascript
复制
<!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>

错误:

代码语言:javascript
复制
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/说:

代码语言:javascript
复制
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.

有人知道我怎么解决这个问题吗?谢谢!

EN

回答 1

Stack Overflow用户

发布于 2017-06-12 18:30:41

Flask将在" templates“目录中查找模板。将html模板移动到templates目录中。它应该是可行的

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44496926

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档