Google App Engine で画像、html ファイル、javascript を使用すると問題が発生します。アプリケーションフォルダーに static というフォルダーがあります。static フォルダーには、「images」、「html」、「javascript」という 3 つのフォルダーがあります。私の app.yaml のハンドラー部分は次のとおりです。
handlers:
- url: /html
static_dir: static/html
- url: /javascript
static_dir: static/javascript
- url: /images
static_dir: static/images
- url: /.*
script: index.app
で画像にアクセスしようとしましたが、
self.response.out.write('<img src="images/image.png">')
そして、jinja2 を使用して html をレンダリングします。
jinja_environment = jinja2.Environment(autoescape=True,
loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), 'html')))
template = jinja_environment.get_template('index.html')
self.response.out.write(template.render(template_values))
jinja のテンプレートが見つからず、イメージも見つからないというエラーが表示されます。アップロードを使用して Google App Engine でファイルを使用するには、これが正しい方法だと思っていましたが、明らかに間違っています。
Google App Engine でフォルダ内のファイルを使用するにはどうすればよいですか?