annot-server/annotserver.py
changeset 2 fc1ab0074e29
parent 0 e1d4d7a8255a
child 13 435d5c15275a
equal deleted inserted replaced
1:1cdebfeb77f9 2:fc1ab0074e29
     6 
     6 
     7 from twisted.application import service, internet, strports
     7 from twisted.application import service, internet, strports
     8 from twisted.internet import reactor
     8 from twisted.internet import reactor
     9 from twisted.python.threadpool import ThreadPool
     9 from twisted.python.threadpool import ThreadPool
    10 from twisted.web import server
    10 from twisted.web import server
       
    11 from twisted.web import resource
    11 from twisted.web.wsgi import WSGIResource
    12 from twisted.web.wsgi import WSGIResource
    12 from twisted.web.static import Data
    13 from twisted.web.static import Data, File
    13 
    14 
    14 from oscserver import OSCServerProtocol
    15 from oscserver import OSCServerProtocol
    15 from websockets import BroadcastServerFactory, AnotationServerFactory
    16 from websockets import BroadcastServerFactory, AnotationServerFactory
    16 from webapp import app
    17 from webapp import app
    17 
    18 
    51 
    52 
    52     rootWs.putChild("broadcast", wsResource)
    53     rootWs.putChild("broadcast", wsResource)
    53     rootWs.putChild("annot", wsAnnotResource)
    54     rootWs.putChild("annot", wsAnnotResource)
    54 
    55 
    55 
    56 
       
    57     webResource = resource.Resource()
       
    58     webResource.putChild(config['static_url'], File(config['static_root']))
    56     # Create the WSGI resource
    59     # Create the WSGI resource
    57     wsgiAppAsResource = WSGIResource(reactor, wsgiThreadPool, app)
    60     wsgiAppAsResource = WSGIResource(reactor, wsgiThreadPool, app)
       
    61     webResource.putChild('', wsgiAppAsResource)
       
    62 
    58 
    63 
    59     # Hooks for twistd
    64     # Hooks for twistd
    60 
    65 
    61     webserver = strports.service('tcp:%d' % config.get('web_port',WEB_PORT), server.Site(wsgiAppAsResource))
    66     webserver = strports.service('tcp:%d' % config.get('web_port',WEB_PORT), server.Site(webResource))
    62     webserver.setServiceParent(s)
    67     webserver.setServiceParent(s)
    63 
    68 
    64     wsserver = strports.service('tcp:%d' % config.get('ws_port',WS_PORT), server.Site(rootWs))
    69     wsserver = strports.service('tcp:%d' % config.get('ws_port',WS_PORT), server.Site(rootWs))
    65     wsserver.setServiceParent(s)
    70     wsserver.setServiceParent(s)
    66 
    71