February 2018
Intermediate to advanced
456 pages
9h 56m
English
We can now start to use our new Jinja2 dependency in our WebServer. First, we need to include it in our imports of service.py:
from .dependencies.jinja2 import Jinja2
Let's now amend our WebServer class to be the following:
class WebServer:
name = 'web_server'
message_service = RpcProxy('message_service')
templates = Jinja2()
@http('GET', '/')
def home(self, request):
messages = self.message_service.get_all_messages()
rendered_template = self.templates.render_home(messages)
return rendered_template
Notice how we have assigned a new attribute, templates, like we did earlier in our MessageService with message_store. Our HTTP entrypoint now talks to our MessageService, retrieves all of the messages in Redis, and uses ...
Read now
Unlock full access