Skip to content

Instantly share code, notes, and snippets.

@michaelfeng
Forked from jmvrbanac/app.py
Created November 21, 2017 16:51
Show Gist options
  • Select an option

  • Save michaelfeng/9ff0a5552db68d75950af8edec6050b0 to your computer and use it in GitHub Desktop.

Select an option

Save michaelfeng/9ff0a5552db68d75950af8edec6050b0 to your computer and use it in GitHub Desktop.

Revisions

  1. @jmvrbanac jmvrbanac created this gist Feb 18, 2016.
    23 changes: 23 additions & 0 deletions app.py
    Original 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)