Skip to content

Commit

Permalink
rename html to template
Browse files Browse the repository at this point in the history
  • Loading branch information
squeaky-pl committed May 29, 2017
1 parent 5e15535 commit 866bca3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
File renamed without changes.
7 changes: 4 additions & 3 deletions examples/8_html/html.py → examples/8_template/template.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# examples/8_html/html.py
# examples/8_template/template.py
from japronto import Application
from jinja2 import Template

Expand All @@ -14,9 +14,10 @@ def example(request):
return request.Response(text='<h1>Some HTML!</h1>', mime_type='text/html')


template = Template('<h1>Hello {{ name }}!</h1>')

# A view could also return a rendered jinja2 template
def jinja(request):
template = Template('<h1>Hello {{ name }}!</h1>')
return request.Response(text=template.render(name='World'),
mime_type='text/html')

Expand All @@ -27,7 +28,7 @@ def jinja(request):
# Add routes to the app
app.router.add_route('/', index)
app.router.add_route('/example', example)
app.router.add_route('jinja2', jinja)
app.router.add_route('/jinja2', jinja)

# Start the server
app.run(debug=True)
Expand Down
2 changes: 1 addition & 1 deletion tutorial/8_html.md → tutorial/8_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Serving HTML from japronto is as simple as adding a MIME type of `text/html` to
Copy and paste following code into a file named `html.py`:

```python
# examples/8_html/html.py
# examples/8_template/template.py
from japronto import Application
from jinja2 import Template

Expand Down

0 comments on commit 866bca3

Please sign in to comment.