Skip to content

Instantly share code, notes, and snippets.

@snaka
Created May 3, 2012 03:28
Show Gist options
  • Select an option

  • Save snaka/2582879 to your computer and use it in GitHub Desktop.

Select an option

Save snaka/2582879 to your computer and use it in GitHub Desktop.
GAEでJinja2を使う
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"
Hello, {{ name }} san.
# 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