PyZombis localstorage@710f0aa
  • Social
    • Runestone in social media:
      Follow @iRunestone Our Facebook Page
    • Help support us:
  • Search
    • Table of Contents
    • Book Index
  • User
    • Assignments
    • Practice
    • Change Course
    • Instructor's Page
    • Progress Page
    • Edit Profile
    • Change Password
    • Register
    • Login
    • Dark Mode
  • Scratch Activecode
  • Help
    • FAQ
    • Instructors Guide
    • About Runestone
    • Report A Problem
  • 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¶

    System Message: WARNING/2 (/home/runner/work/PyZombis/PyZombis/_sources/lectures/TWP65/TWP65_3_en.rst, line 93)

    Title underline too short.

    Accessories
    ----------
    
    • Web2py Appliances

    • Email Contact Form

    • Sudoku Solver

    • Train Counter Game

    • Quiz Builder

    • EcardsOnMap (it’s huge…)

    You have attempted of activities on this page

| Back to top

© Copyright 2021 Python Argentina et al.. Created using Runestone 5.8.1.