def template_test()

in demo-app/app.py [0:0]


def template_test():
    """
    Handle the root path for this app. Renders a simple web page displaying a
    message. The default message is Hello World but this can be overridden by
    the use of a parameter: ?string=Test
    """

    tracer = execution_context.get_opencensus_tracer()

    # Trace Pub/Sub call using Context Manager
    with tracer.start_span() as pubsub_span:
        pubsub_span.name = '[{}]{}'.format('publish', 'Pub/Sub')
        pubsub_span.add_attribute('Topic Path', topic_path)

        string = request.args.get('string')
        string = string if string else 'Hello World'
        print('Publishing string: %s' % string)
        publisher.publish(topic_path, data=string.encode('utf-8')).result()

        return render_template('template.html', my_string=string)