python - Newbie question regarding @app.route("/index")
问题描述
I was messing around with learning python myself, was working on a little HTML website using python. Anyone could please explain the differences between the two applications below?
When it's written like this it doesn't work. (this is an example I got from the top result from google)
@app.route('/index')
def index():
return render_template('index.html')
doesn't works
but when I include the full link .html
@app.route('/index.html')
def index():
return render_template('index.html')
it works?
解决方案
好的,假设您有 index.html 和 index.png 您的代码不知道需要什么文件。即使您只有一个文件,阻止您的代码打开其他文件也是一种安全。文件扩展名是文件的一部分。
推荐阅读
- python - Pyspark动态框架无缘无故添加额外的空白列
- xml - 如何使用 JAXB 和 xsd 模式验证 xml 元素是否为空?
- python - Python 获取 IDE linter 以从 pythonnet 的 clr 中的系统导入中查看
- .net-core - 如何为 f# 应用程序设置 Windows 资源管理器图标
- javascript - 循环 JSON 数组中的每个 x 对象
- ruby-on-rails - 根据Rails中params中的值设置全局变量
- mysql - 如何根据另一个表中的列和原始表中的列对表中的值进行排序?
- r - 如何将分类变量二分为具有 1 和 0 的新变量但保持 NA?
- teradata - Teradata 结果集返回列的最小长度
- php - 在数组中查找字符串