Last active
December 30, 2015 15:29
-
-
Save j2labs/7848611 to your computer and use it in GitHub Desktop.
A Brubeck demo showing how Jinja2 support works with the new plugin system.
This file contains 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
#!/usr/bin/env python | |
from brubeck.servers.web import WebServer | |
from brubeck.handlers.web import WebMessageHandler | |
from brubeck.connections import WSGIConnection | |
from brubeck_templates.plugins import Jinja2Plugin | |
import sys | |
class DemoHandler(WebMessageHandler): | |
def get(self): | |
name = self.get_argument('name', 'dude') | |
body = self.plugins.jinja2.render('success.html', name=name) | |
return self.render(body=body) | |
app = WebServer(msg_conn=WSGIConnection(), | |
handlers=[(r'^/brubeck', DemoHandler)], | |
plugins=[Jinja2Plugin('./templates/jinja2')]) | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mind hooking me up with a link for an example too? The docs are kinda dense.