3. Visitor Accounts¶
Edit default.py controller
def index():
if not session.counter:
session.counter = 1
else:
session.counter += 1
return dict(msg="Python Zumbi", cont=session.counter)
default/index view
<html>
<head></head>
<body>
<h1>{{=msg}}</h1>
<h2>Visitors: {{=cont}}</h2>
</body>
</html>
Different visitors have different counters
3.1. Two pages¶
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
def first():
return dict()
def second():
return dict()
Create the default/first view
{{extend ‘layout.html’}}
What is your name?
<form action=”second”>
<input name=”name” />
<input type=”submit” />
</form>
Create the default/second view
{{extend ‘layout.html’}}
<h1>Hello {{=request.vars.name}}</h1>
3.2. Accessories¶
Email Contact Form
Sudoku Solver
Train Counter Game
Quiz Builder
EcardsOnMap (it’s huge…)
You have attempted of activities on this page