Jinja2 を Google AppEngine と連携させる作業を行っています。main.py コードには次のものがあります。
import os
import webapp2
import jinja2
jinja_environment = jinja2.Environment(autoescape=True,
loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')))
class MainPage(webapp2.RequestHandler):
def get(self):
template_values = {
'name': 'SomeGuy',
'verb': 'extremely enjoy'
}
template = jinja_environment.get_template('index.html')
self.response.out.write(template.render(template_values))
webapp2.WSGIApplication([('/', MainPage)], debug=True)
これは何時間も私を殺してきました。助けていただければ幸いです。
アップデート:
状況を更新するためにコードを少し変更しました。ログは私に言っています:
ImportError: <module 'main' from '/base/data/home/apps/s~devpcg/1.359633215335673018/main.pyc'> has no attribute app
上記のコードはすべて私の main.py フォルダーからのものです。main.py ファイルと同じディレクトリにある templates というフォルダーにファイル index.html があります。