Flask Greetings

Hello, World!

Flask Intro

Jinja2 pre-processor code. This code shows a variable name within double curly/squiggly brackets, or the variable syntax of Jinja2. The variable is replaced with the value before the HTML is given to the browser by Flask/Jinja2 (a pre-processor means a step before code is transferred to another tool or engine.

HTML input form. A form action gathers input interacts between HTML and the backend server, POST via HTTP is the method of interaction.

Python backend COPY CODE. This code, contained in a Python function, sets up the "name=" variable. The name variable is passed to the HTML (greet.html) via Flask. This code contains "if statements", these statements are referred to as selection statements by College Board. Most developers refer to if statements as conditionals. This code tests to see if input is entered from the HTML Form. If input is set then Python variable "name" set the Jinja2 variable "name" (name=name) with the value from the HTML form. The default/else condition (last statement in function), sets "name" to a constant value name="World". Conditional logic is fundamental to all programming languages. Observe this closely, make sure you understand it thoroughly.

HTML block COPY CODE. The HTML pre-processor and input form put together. Try view-source through browser to see what happens to pre-processor code. Tech Talk mini-lab will be to add "greet" to your project.

Contact Us