我决定用烧瓶来介绍。我从HelloWorld-page开始:
main.py:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def hello_world():
return render_template('index.html')
app.run()
index.html(与main.py在同一目录中):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Main</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
但是当我打开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 :(得分:1)
创建一个名为templates
的目录并在那里移动index.html
。这就是Flask寻找模板文件的地方。