我在根目錄的「靜態」子目錄中有一個html文件「listagem.html」。 我想使用「listagem.html」作爲jinja2的模板。GAE/Python/jinja2 /如何引用加入語句中的子目錄
我想這3個加入公式:
第一:
jinja_environment = jinja2.Environment(
autoescape = True,
loader = jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), 'static')))
二:
jinja_environment = jinja2.Environment(
autoescape = True,
loader = jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), 'static/')))
三:
jinja_environment = jinja2.Environment(
loader = jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), '/static')))
template = jinja_environment.get_template('listagem.html')
self.response.out.write(template.render(template_values))
,並收到此錯誤:
file not accessible: 'C:\\Users\\Me\\AppEngine\\MyAppRoot\\static\\listagem.html'
我在做什麼錯?
坦克求救。
可以接受的答案,如果它的工作,幫助別人誰看的問題 – thikonom
坦克的幫助。它運行良好。 – RRBaldi
只是爲了擴大這個看起來很明顯的東西,但如果一個文件與'skip_files'正則表達式匹配,你也會得到'IOError'。所以,它不能是靜態的,路徑不應該被跳過。 – hjc1710