Skip to main content
 首页 » 编程设计

python之使用模板时 flask 错误

2025年04月02日12lovecherry

<分区>

尝试使用 flask 启动服务器并出现此错误。我的模板文件在模板文件夹(flaskr/templates)

import sqlite3 
from flask import Flask, request, session, g, redirect, url_for, \ 
     abort, render_template, flash 
 
app = Flask(__name__) 
 
@app.route('/templates/') 
@app.route('/templates/<name>') 
def hello(name=None): 
    return render_template('index.html', name=name) 
 
if __name__ == '__main__': 
    app.run() 

我得到错误:

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.