-
-
Save michaelfeng/9ff0a5552db68d75950af8edec6050b0 to your computer and use it in GitHub Desktop.
Revisions
-
jmvrbanac created this gist
Feb 18, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ import os import falcon import jinja2 def load_template(name): path = os.path.join('templates', name) with open(os.path.abspath(path), 'r') as fp: return jinja2.Template(fp.read()) class ThingsResource(object): def on_get(self, req, resp): template = load_template('awesome.j2') resp.status = falcon.HTTP_200 resp.content_type = 'text/html' resp.body = template.render(something='testing') app = falcon.API() things = ThingsResource() app.add_route('/things', things)