diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2006-07-14 16:56:31 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2006-07-14 16:56:31 +0000 |
| commit | 1430fa61856eb2f52e1f59b2fd7cda01f6f0405b (patch) | |
| tree | 6c93f191acf02c3895e0b7ff87fb1998219e7457 /lib/python/Plugins/Extensions/WebInterface/plugin.py | |
| parent | 73483209d943d04a3299462d2412ff5c3ef32a64 (diff) | |
| download | enigma2-1430fa61856eb2f52e1f59b2fd7cda01f6f0405b.tar.gz enigma2-1430fa61856eb2f52e1f59b2fd7cda01f6f0405b.zip | |
add proof-of-concept web interface
Diffstat (limited to 'lib/python/Plugins/Extensions/WebInterface/plugin.py')
| -rw-r--r-- | lib/python/Plugins/Extensions/WebInterface/plugin.py | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/lib/python/Plugins/Extensions/WebInterface/plugin.py b/lib/python/Plugins/Extensions/WebInterface/plugin.py index 0f7e2bbd..c61424c8 100644 --- a/lib/python/Plugins/Extensions/WebInterface/plugin.py +++ b/lib/python/Plugins/Extensions/WebInterface/plugin.py @@ -1,14 +1,41 @@ from Plugins.Plugin import PluginDescriptor +sessions = [ ] + def startWebserver(): from twisted.internet import reactor - from twisted.web2 import server, http, static - toplevel = static.File("/hdd") - site = server.Site(toplevel) + from twisted.web2 import server, http, static, resource, stream + import webif + + class ScreenPage(resource.Resource): + def render(self, req): + global sessions + if sessions == [ ]: + return http.Response("please wait until enigma has booted") + + s = stream.ProducerStream() + webif.renderPage(s, req, sessions[0]) # login? + return http.Response(stream=s) + + class Toplevel(resource.Resource): + addSlash = True + + def render(self, req): + return 'Hello! you want probably go to <a href="/test">the test</a> instead.' + + child_test = ScreenPage() # "/test" + child_hdd = static.File("/hdd") + + site = server.Site(Toplevel()) reactor.listenTCP(80, http.HTTPFactory(site)) def autostart(reason, **kwargs): + if "session" in kwargs: + global sessions + sessions.append(kwargs["session"]) + return + if reason == 0: try: startWebserver() @@ -16,4 +43,4 @@ def autostart(reason, **kwargs): print "twisted not available, not starting web services" def Plugins(**kwargs): - return PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart) + return PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart) |
