summaryrefslogtreecommitdiff
path: root/examples/contrib/sessions.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/contrib/sessions.py')
-rw-r--r--examples/contrib/sessions.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/examples/contrib/sessions.py b/examples/contrib/sessions.py
index ecf464a2..c5eef576 100644
--- a/examples/contrib/sessions.py
+++ b/examples/contrib/sessions.py
@@ -1,11 +1,11 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from werkzeug.contrib.sessions import SessionMiddleware
+from werkzeug.contrib.sessions import SessionStore
from werkzeug.serving import run_simple
-from werkzeug.contrib.sessions import SessionStore, SessionMiddleware
class MemorySessionStore(SessionStore):
-
def __init__(self, session_class=None):
SessionStore.__init__(self, session_class=None)
self.sessions = {}
@@ -23,21 +23,22 @@ class MemorySessionStore(SessionStore):
def application(environ, start_response):
- session = environ['werkzeug.session']
- session['visit_count'] = session.get('visit_count', 0) + 1
+ session = environ["werkzeug.session"]
+ session["visit_count"] = session.get("visit_count", 0) + 1
- start_response('200 OK', [('Content-Type', 'text/html')])
- return ['''
- <!doctype html>
+ start_response("200 OK", [("Content-Type", "text/html")])
+ return [
+ """<!doctype html>
<title>Session Example</title>
<h1>Session Example</h1>
- <p>You visited this page %d times.</p>
- ''' % session['visit_count']]
+ <p>You visited this page %d times.</p>"""
+ % session["visit_count"]
+ ]
def make_app():
return SessionMiddleware(application, MemorySessionStore())
-if __name__ == '__main__':
- run_simple('localhost', 5000, make_app())
+if __name__ == "__main__":
+ run_simple("localhost", 5000, make_app())