Created
May 3, 2012 03:28
-
-
Save snaka/2582879 to your computer and use it in GitHub Desktop.
GAEでJinja2を使う
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| application: webapp2 | |
| version: 1 | |
| runtime: python27 | |
| api_version: 1 | |
| threadsafe: yes | |
| handlers: | |
| - url: .* | |
| script: main.app | |
| libraries: | |
| - name: webapp2 | |
| version: "2.5.1" | |
| - name: jinja2 | |
| version: "2.6" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Hello, {{ name }} san. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| import os | |
| import webapp2 | |
| from jinja2 import Environment, FileSystemLoader | |
| env = Environment( | |
| loader = FileSystemLoader(os.path.dirname(__file__)) | |
| ) | |
| class MainHandler(webapp2.RequestHandler): | |
| def get(self): | |
| template = env.get_template('hello.html') | |
| self.response.out.write(template.render(name=u'ほげほげ')) | |
| app = webapp2.WSGIApplication([('/', MainHandler)], | |
| debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment