Here are the examples of the python api twisted.web.rewrite.alias taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
0
Example 1
Project: jolicloud-daemon Source File: main.py
def start():
root = static.File(os.environ['JPD_HTDOCS_PATH'])
root.processors = { '.rpy': script.ResourceScript }
root = rewrite.RewriterResource(root, rewrite.alias('cgi-bin/get_icon.py', 'get_icon.rpy'))
site = JolicloudWSSite(root)
site.addHandler('/jolicloud/', JolicloudWSHandler)
# Setting up the log file path
if os.environ.get('JPD_SYSTEM', '0') == '1':
if os.getuid():
log.err('You must be root to run this daemon in system mode.')
exit()
log_path = '/var/log'
else:
try:
import xdg.BaseDirectory
log_path = xdg.BaseDirectory.save_data_path('Jolicloud', 'jolicloud-daemon')
except ImportError:
log_path = os.path.join(os.getenv('HOME'), '.local', 'share', 'Jolicloud', 'jolicloud-daemon')
port = int(os.environ.get('JPD_PORT', 804 if os.environ.get('JPD_SYSTEM', None) else 8004))
# http://twistedmatrix.com/docuements/9.0.0/web/howto/using-twistedweb.html#auto5
if os.environ.get('JPD_DEBUG', '0') == '1':
log.startLogging(sys.stdout)
log.startLogging(LogFile('jolicloud-daemon.log', log_path, maxRotatedFiles=2))
reactor.listenTCP(port, site)
else:
log.startLogging(LogFile('jolicloud-daemon.log', log_path, maxRotatedFiles=2))
reactor.listenTCP(port, site, interface='127.0.0.1')
# TODO, use random port for session daemon
# We load the plugins:
if os.environ.get('JPD_SYSTEM', '0') == '1':
log.msg('We load the system plugins.')
plugins = getPlugins(ijolidaemon.ISystemManager, managers)
else:
log.msg('We load the session plugins.')
plugins = getPlugins(ijolidaemon.ISessionManager, managers)
for plugin in plugins:
log.msg(plugin.__class__.__name__)
reactor.run()