#!/usr/bin/python # -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil; -*- # # aggiungiamo la directory corrente al path (se non presente) # import sys wsgilib = '/'.join( __file__.split('/')[:-1] ) if wsgilib not in sys.path: sys.path.insert(0, wsgilib) # # inizializzazione path per templating # from decorators import WSGITemplate WSGITemplate( basedir='views' ) # # inizializzazione connessione al db ( mysql ) # from decorators import WSGIMySQL WSGIMySQL( dict( DB = "mywiki", HOST = "localhost", USER = "corso", PASSWORD = "pwdcorso" ), dict( DB = "shootout", HOST = "localhost", USER = "root", PASSWORD = "server", ALIAS = "shoot" ), ) # # importazione handler definiti esternamente # from router import WSGIRouter, WSGISmartRouter # # index: esempio minimo di applicazione WSGI (pagina iniziale) # def index( environ, start_response ): start_response( '200 OK', [('content-type', 'text/html')] ) return [ 'Index was here' ] # # hello: esempio minimo di applicazione WSGI # def hello( environ, start_response ): start_response( '200 OK', [('content-type', 'text/html')] ) return [ 'Simon says: Hello world!' ] # # fallback: mostra tutti i parametri disponibili all'applicazione WSGI # def fallback( environ, start_response ): from pprint import pformat start_response( '200 OK', [('Content-Type', 'text/html')] ) return [ '-- EMBEDDED MODE --' if not environ.get('mod_wsgi.process_group','') else '-- DAEMON MODE --', '
', pformat( environ, width=132 ).replace('\n','