これが私のmain.pyファイルと、私が使用しているJinja2テンプレートによってレンダリングしたいhtmlファイルです:
main.py
import os
import webapp2
import jinja2
from google.appengine.ext import db
template_dir = os.path.join(os.path.dirname(__file__), 'templates')
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir), autoescape=True)
class Handler(webapp2.RequestHandler):
def write(self, *a, **kw):
self.response.out.write(*a, **kw)
def render_str(self, template, **params):
t = jinja_env.get_template(template)
return t.render(params)
def render(self, template, **kw):
self.write(self.render_str(template, **kw))
class MainPage(Handler):
def get(self):
self.render("temp.html")
app = webapp2.WSGIApplication([('/', MainPage)], debug=True)
temp.html
<!DOCTYPE html>
<html>
<head>
<style>
div#logo
{
position: absolute;
margin-top:5%;
margin-left:25%;
}
div#cart
{
position: absolute;
margin-left:87%;
margin-top:-2px;
}
</style>
</head>
<body>
<div id = logo><img src="logo.png" height = 60% width = 60%></div>
<div id = cart><img src="cart.jpg" height = 75 px ></div>
</body>
</html>
これで、必要な画像と共に html ファイルをアプリ エンジン アプリケーション ディレクトリのテンプレート フォルダーに保存しました。また、ブラウザで実行すると、html ファイルは正常に動作します。ただし、GAE を使用してアプリケーションを実行すると、空白の画面しか表示されません。なぜそうなのですか?HTML ファイルがレンダリングされないのはなぜですか?