Return to Snippet

Revision: 22532
at January 14, 2010 09:47 by manatlan


Initial Code
#!/usr/bin/python
# -*- coding: utf-8 -*-
import bottle as web
from beaker.middleware import SessionMiddleware

@web.route('/')
def index():
    session=web.request.environ["beaker.session"]
    if "cpt" in session:
        session["cpt"]+=1
    else:
        session["cpt"]=1
    return "cpt:"+str(session["cpt"])

if __name__=="__main__":

    session_opts = {
        "session.type": "file",
        'session.cookie_expires': True,
        'session.auto': True,
        'session.data_dir': "cache",
    }

    app = web.default_app()
    
    app = SessionMiddleware(app, session_opts)

    web.run(app=app,reloader=True)

Initial URL


Initial Description


Initial Title
python web with bottle and session (beaker)

Initial Tags
python, web

Initial Language
Python