/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/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)