Question 17
Consider the following Python script that processes command line arguments and uses Jinja2 templates.
python: app.py
import sysfrom jinja2 import Template
pre_message = sys.argv[1] if len(sys.argv) > 1 else ""pre_language = sys.argv[2] if len(sys.argv) > 2 else "unknown"
post_message = pre_message.strip().lower().replace(" ", "_")post_language = pre_language.capitalize()
template_string = """<div> <h1>{{ post_message | upper }}</h1> <p>Message: {{ post_message }}</p> <p>Language: {{ post_language }}</p> <p>Count: {{ pre_message | length }}</p></div>"""
template = Template(template_string)output = template.render( pre_message = pre_message, post_message = post_message, post_language = post_language)
print(output)If the script is run with the command:
bash
python app.py " Hello World " "python"What will be the output for the following template variables?