コード例 #1
0
def main():
    # the start and stop stuff will be handled from the freevo script

    if os.path.isdir(os.path.join(os.environ['FREEVO_PYTHON'], 'www/htdocs')):
        docRoot = os.path.join(os.environ['FREEVO_PYTHON'], 'www/htdocs')
    else:
        docRoot = os.path.join(config.SHARE_DIR, 'htdocs')

    root = static.File(docRoot)
    root.processors = {
        '.rpy': script.ResourceScript,
    }

    child_resources = []
    child_resources.extend(config.VIDEO_ITEMS)
    child_resources.extend(config.AUDIO_ITEMS)
    child_resources.extend(config.IMAGE_ITEMS)
    child_resources.extend([('Recorded TV', config.TV_RECORD_DIR)])
    child_resources.extend([('Webserver Cache', config.WEBSERVER_CACHEDIR)])
    for item in child_resources:
        if isinstance(item, tuple) and len(item) == 2:
            (title, path) = item
            root.putChild(path.replace("/", "_"), static.File(path))

    root.putChild('vhost', vhost.VHostMonsterResource())
    rewriter = rewrite.RewriterResource(root, helpimagesrewrite)
    site = server.Site(rewriter)

    try:
        application = service.Application('web', uid=eval(uid), gid=eval(gid))
    except Exception, e:
        application = service.Application('web')
        print e
コード例 #2
0
ファイル: webserver.py プロジェクト: 1147279/SoftwareProject
def main():
    # the start and stop stuff will be handled from the freevo script

    logfile = '%s/%s-%s.log' % (config.LOGDIR, appname, os.getuid())
    log.startLogging(open(logfile, 'a'))

    if os.path.isdir(os.path.join(os.environ['FREEVO_PYTHON'], 'www/htdocs')):
        docRoot = os.path.join(os.environ['FREEVO_PYTHON'], 'www/htdocs')
    else:
        docRoot = os.path.join(config.SHARE_DIR, 'htdocs')

    root = static.File(docRoot)
    root.processors = {
        '.rpy': script.ResourceScript,
    }

    child_resources = []
    child_resources.extend(config.VIDEO_ITEMS)
    child_resources.extend(config.AUDIO_ITEMS)
    child_resources.extend(config.IMAGE_ITEMS)
    child_resources.extend([('Recorded TV', config.TV_RECORD_DIR)])
    child_resources.extend([('Webserver Cache', config.WEBSERVER_CACHEDIR)])
    for item in child_resources:
        if isinstance(item, tuple) and len(item) == 2:
            (title, path) = item
            root.putChild(path.replace("/", "_"), static.File(path))

    root.putChild('vhost', vhost.VHostMonsterResource())
    rewriter = rewrite.RewriterResource(root, helpimagesrewrite)
    if (config.DEBUG == 0):
        site = server.Site(rewriter, logPath='/dev/null')
    else:
        site = server.Site(rewriter)

    application = app.Application('web')
    application.listenTCP(config.WEBSERVER_PORT, site)
    application.run(save=0)
コード例 #3
0
ファイル: web.py プロジェクト: swift1911/twisted
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
# See LICENSE for details.


# This web server makes it possible to put it behind a reverse proxy
# transparently. Just have the reverse proxy proxy to 
# host:port/vhost/http/external-host:port/
# and on redirects and other link calculation, the external-host:port will
# be transmitted to the client.

from twisted.internet import reactor
from twisted.web import static, server, vhost, twcgi, script, trp

root = static.File("static")
root.processors = {
            '.cgi': twcgi.CGIScript,
            '.php3': twcgi.PHP3Script,
            '.php': twcgi.PHPScript,
            '.epy': script.PythonScript,
            '.rpy': script.ResourceScript,
            '.trp': trp.ResourceUnpickler,
}
root.putChild('vhost', vhost.VHostMonsterResource())
site = server.Site(root)
reactor.listenTCP(1999, site)
reactor.run()
コード例 #4
0
ファイル: web.py プロジェクト: zerospam/twisted
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
This demonstrates a web server which can run behind a name-based virtual hosting
reverse proxy.  It decodes modified URLs like:

    host:port/vhost/http/external-host:port/

and dispatches the request as if it had been received on the given protocol,
external host, and port.

Usage:
    python web.py
"""

from twisted.internet import reactor
from twisted.web import static, server, vhost, twcgi, script

root = static.File("static")
root.processors = {
    ".cgi": twcgi.CGIScript,
    ".epy": script.PythonScript,
    ".rpy": script.ResourceScript,
}
root.putChild(b"vhost", vhost.VHostMonsterResource())
site = server.Site(root)
reactor.listenTCP(1999, site)
reactor.run()
コード例 #5
0
ファイル: service.py プロジェクト: mindpool/bot-prakasha-ke
def makeService(options):
    # primary setup
    application = service.Application(meta.display_name)
    services = service.IServiceCollection(application)

    # setup message server
    serverFactory = ServerFactory()
    serverFactory.protocol = Listener
    serverFactory.publisher = PublisherFactory()

    msgServer = internet.TCPServer(config.listener.port, serverFactory)
    msgServer.setName(config.listener.servicename)
    msgServer.setServiceParent(services)

    # setup IRC message client
    if config.irc.sslEnabled:
        msgService = internet.SSLClient(config.irc.server, config.irc.port,
                                        serverFactory.publisher,
                                        ClientContextFactory())
    else:
        msgService = internet.TCPClient(config.irc.server, config.irc.port,
                                        serverFactory.publisher)
    msgService.setName(config.irc.servicename)
    msgService.setServiceParent(services)

    # setup IRC log client
    logger = LoggerFactory(config.irc.server, config.log.channels)
    logService = internet.TCPClient(config.irc.server, config.irc.port, logger)
    logService.setName(config.log.servicename)
    logService.setServiceParent(services)

    # setuplog rotator
    rotService = internet.TimerService(config.log.rotate.checkInterval,
                                       logger.rotateLogs, logService)
    rotService.setName(config.log.rotate.servicename)
    rotService.setServiceParent(services)

    # setup log file web server
    webroot = static.File(config.log.http.docRoot)
    if config.log.http.vhostEnabled:
        vResource = vhost.VHostMonsterResource()
        webroot.putChild('vhost', vResource)
    if config.log.http.auth == 'basic':
        guarded = auth.guardResourceWithBasicAuth(webroot,
                                                  config.log.http.realm,
                                                  config.log.http.users)
        site = server.Site(guarded)
    else:
        site = server.Site(webroot)
    webserver = internet.TCPServer(config.log.http.port, site)
    webserver.setName(config.log.http.servicename)
    webserver.setServiceParent(services)

    # setup ssh access to a Python shell
    interpreterType = dreamssh_const.PYTHON
    sshFactory = getShellFactory(interpreterType,
                                 app=application,
                                 services=services)
    sshserver = internet.TCPServer(config.ssh.port, sshFactory)
    sshserver.setName(config.ssh.servicename)
    sshserver.setServiceParent(services)
    return services
コード例 #6
0
def CreateWebServer(sHost, iPort):
	oWebNode = vhost.NameVirtualHost()
	oWebNode.addHost(sHost, vhost.VHostMonsterResource())
	reactor.listenTCP(iPort, CDelaySite(oWebNode))
	return oWebNode
コード例 #7
0
from twisted.web import vhost

resource = vhost.VHostMonsterResource()