zoukankan      html  css  js  c++  java
  • python web with bottle and session (beaker)

    python web with bottle and session (beaker)

    http://icodesnip.com/snippet/python/python-web-with-bottle-and-session-beaker
        ?
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
           
        #!/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)
        Comments

  • 相关阅读:
    中芯国际唐镇生活园区二期奠基 助力员工安居乐业
    权限管理架构
    不登录电脑启动程序
    Nagios 系统监控
    JieBaNet+Lucene.Net
    FontAwesome 图标
    Net多线程编程
    Scala Control Structures
    OAuthLogin2.0
    Telnet服务器和客户端请求处理
  • 原文地址:https://www.cnblogs.com/lexus/p/3454761.html
Copyright © 2011-2022 走看看