Hob*_*nob 1 html flask python-2.7
Flask 的新手并且对 python 有一些经验,当使用 render_template 时,它根本不渲染模板,也不会发出任何错误。代码在这里:
from flask import Flask, render_template
app = Flask(__name__, template_folder= "/templates")
@app.route("/")
def index():
#return("Index str")
return render_template("index.html")
@app.route("/crawler")
def crawler():
return("WebCrawler str")
return render_template("crawler.html")
if __name__ == "__main__":
app.run()
app.debug = True
Run Code Online (Sandbox Code Playgroud)
HTML here(相当确定的文件层次结构是正确的)。
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='style.css')}}">
<meta charset = "utf-8">
<title> Index</title>
<head>
<body>
<p> This webserver hosts all webapps and will showcase any unfinished applications.
</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6563 次 |
| 最近记录: |