首页 > 代码库 > Web2py也有意思的

Web2py也有意思的

多学学,以后可以方便的自己写代码了。

对于各种WEB框架,这也是打一个基础的时候。

相信学入门了,对PHP的,JAVA的WEB框架,都是能理解更深入的。

def index():
    """
    example action using the internationalization operator T and flash
    rendered by views/default/index.html or views/generic.html

    if you need a simple wiki simply replace the two lines below with:
    return auth.wiki()
    """
    if not session.counter:
        session.counter = 1
    else:
        session.counter += 1
    #response.flash = T("Welcome to web2py!")
    return dict(message="Hello, Sky from MyApp!", counter=session.counter)

def first():
    form = SQLFORM.factory(Field(visitor_name, requires=IS_NOT_EMPTY()))
    if form.process().accepted:
        session.visitor_name = form.vars.visitor_name
        redirect(URL(second))
    return dict(form=form)

def second():
    if not request.function==first and not session.visitor_name:
        redirect(URL(first))
    return dict()