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

  • 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

  • Web2py Appliances

  • Email Contact Form

  • Sudoku Solver

  • Train Counter Game

  • Quiz Builder

  • EcardsOnMap (it’s huge…)

    On a scale from 1 (needs improvement) to 3 (excellent), how would you rate this chapter?
  • 1
  • 2
  • 3
You have attempted of activities on this page