你可以将变量名放在views.py函数中。例如:
# you can also use a particular data type such as int,str# @app.route('post/<int:id>', methods=['GET', 'POST'])@app.route('post/<variable>', methods=['GET'])def daily_post(variable): #do your pre here return render_template("template.html",para1=meter1, para2=meter2)为了使数据库信息显示在你的站点上,你需要将参数传递到模板中。因此,在模板中,你将引用以下参数:
<td>Post Author: {{ para1.author }}</td><td>Post Body: {{ para1.body }}</td><td>Date Posted: [{{ para2 }}] times</td>然后,当你访问mysite.com/post/anything_here时,“ anything_here”将进入你的函数并根据需要进行评估。你可能还需要设置404页面处理,以防有人尝试手动输入帖子:
@app.errorhandler(404)def not_found_error(error): return render_template('404.html', pic=pic), 404


