1 from Plugins.Plugin import PluginDescriptor
6 from twisted.internet import reactor
7 from twisted.web2 import server, http, static, resource, stream, http_headers, responsecode
8 from twisted.python import util
11 class ScreenPage(resource.Resource):
12 def __init__(self, path):
15 def render(self, req):
18 return http.Response(200, stream="please wait until enigma has booted")
20 s = stream.ProducerStream()
21 webif.renderPage(s, self.path, sessions[0]) # login?
22 return http.Response(stream=s)
24 def locateChild(self, request, segments):
25 path = '/'.join(["web"] + segments)
30 return ScreenPage(path), ()
32 class Toplevel(resource.Resource):
35 def render(self, req):
36 return http.Response(responsecode.OK, {'Content-type': http_headers.MimeType('text', 'html')},
37 stream='Hello! you want probably go to <a href="/test">the test</a> instead.')
39 child_web = ScreenPage("/") # "/web"
40 child_hdd = static.File("/hdd")
41 child_webdata = static.File(util.sibpath(__file__, "web-data"))
43 site = server.Site(Toplevel())
45 reactor.listenTCP(80, http.HTTPFactory(site))
47 def autostart(reason, **kwargs):
48 if "session" in kwargs:
50 sessions.append(kwargs["session"])
57 print "twisted not available, not starting web services"
59 def Plugins(**kwargs):
60 return PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart)