Edit default.py controller
default/index view
Different visitors have different counters
We will create two pages
The first asks for the name in a form
Then we will be redirected to the second
The second will give a greeting with the name
Include in the default.py controller
Create the default/first view
Create the default/second view
Email Contact Form
Sudoku Solver
Train Counter Game
Quiz Builder
EcardsOnMap (it’s huge…)
3. Visitor Accounts¶
def index():
if not session.counter:
session.counter = 1
else:
session.counter += 1
return dict(msg="Python Zumbi", cont=session.counter)
<html>
<head></head>
<body>
<h1>{{=msg}}</h1>
<h2>Visitors: {{=cont}}</h2>
</body>
</html>
3.1. Two pages¶
def first():
return dict()
def second():
return dict()
{{extend ‘layout.html’}}
What is your name?
<form action=”second”>
<input name=”name” />
<input type=”submit” />
</form>
{{extend ‘layout.html’}}
<h1>Hello {{=request.vars.name}}</h1>
3.2. Accessories¶
System Message: WARNING/2 (/home/runner/work/PyZombis/PyZombis/_sources/lectures/TWP65/TWP65_3_en.rst, line 93)
Title underline too short.
Accessories
----------
You have attempted of activities on this page