python web with bottle and session (beaker)
2013-12-02 21:58
495 查看
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
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
相关文章推荐
- Python Programming with the Java(TM) Class Libraries: A Tutorial for Building Web and Enterprise App
- Professional Python Frameworks: Web 2.0 Programming with Django and Turbogears
- HAR with Python WebDriver and BrowserMob Proxy
- python bottle框架使用beaker支持session
- How To Crawl A Web Page with Scrapy and Python 3
- implementaion bottle session with beaker
- Django push: Using Server-Sent Events and WebSocket with Django
- Using MongoDB with Web API and ASP.NET Core
- Mini-Tutorial: Saving Tweets to a Database with Python and CouchDB, a free NoSQL database.
- python问题:ValueError: operands could not be broadcast together with shapes (100,3) (3,1)
- Page needs a session and none is available] with root cause
- C# WebAPI with HttpWebRequest, HttpWebResponse and HttpContext Example
- Setting up Django and your web server with uWSGI and nginx
- Cannot start session without errors, please check errors given in your PHP and/or webserver log
- use python and django make an web service
- 基于Problem Solving with Algorithms and Data Structures using Python的学习记录(3)——Basic Data Structures
- Rapid GUI Programming with Python and Qt (Prentice Hall Open Source, Software Development) (Hardcover) Oct.2007.eBook-BBL
- Qr-Code encode and decode with python+qrcode+zbar
- Automating web tests with FitNesse and Selenium
- 【Python web 开发】 bottle 简单教程 (四)