#!/usr/bin/python # -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil; -*- from decorators import WSGISimpleAuth # decoratore ( singleton ) auth = WSGISimpleAuth() @auth.require() def application( environ, start_response ): storage = environ['auth.storage'] import cgi post_environ = environ.copy() post_environ['QUERY_STRING'] = '' post = cgi.FieldStorage( fp=environ['wsgi.input'], environ=post_environ, keep_blank_values=True ) if 'password' in post: password = post['password'].value storage['permissions'] = [ 'auth' ] html = [ "You are logged in, now you can see the Secret page.", ] else: storage['timeout'] = -1 html = [ "
", ] start_response( '200 OK', [('content-type', 'text/html; charset=utf-8')] ) return html