【发布时间】:2012-12-12 11:53:01
【问题描述】:
我已经在安静的几个地方阅读了应该将提供静态文件的地方留给服务器,例如在这个SO question 的几个答案中。但我使用的是 OpenShift PaaS,不知道如何在那里修改 .htaccess 文件。
我遇到了这个piece of code,它通过模板提供站点地图。我在我的应用程序上为站点地图和 robots.txt 都这样做了,就像这样 -
@app.route("/sitemap.xml")
def sitemap_xml():
response= make_response(render_template("sitemap.xml"))
response.headers['Content-Type'] = 'application/xml'
return response
@app.route("/robots.txt")
def robots_txt():
return render_template("robots.txt")
这样做有什么害处,还是我的方法可以?
【问题讨论】:
标签: python flask static-files