add Interface to IPKG under http://dm7025/ipkg
[enigma2-plugins.git] / webinterface / src / WebChilds / Toplevel.py
1 from twisted.web2 import resource, static, responsecode, http, http_headers
2 from twisted.python import util
3
4 from Components.config import config
5
6 from Plugins.Extensions import WebInterface
7 from Screenpage import ScreenPage
8 from MovieStreamer import MovieStreamer
9 from Screengrab import GrabResource
10 from IPKG import IPKGResource
11
12 class Toplevel(resource.Resource):
13     addSlash = True
14     def __init__(self,session):
15         self.session = session
16         resource.Resource.__init__(self)
17         
18         self.putChild("web",ScreenPage(self.session,util.sibpath(WebInterface.__file__, "web"))) # "/web/*"
19         self.putChild("webdata",static.File(util.sibpath(WebInterface.__file__, "web-data"))) # FIXME: web-data appears as webdata
20         self.putChild("wap",static.File(util.sibpath(WebInterface.__file__, "wap"))) # static pages for wap
21         self.putChild("movie",MovieStreamer())
22         self.putChild("grab",GrabResource())
23         self.putChild("ipkg",IPKGResource())
24         
25         if config.plugins.Webinterface.includehdd.value:
26             self.putChild("hdd",static.File("/hdd"))
27         
28     def render(self, req):
29         fp = open(util.sibpath(WebInterface.__file__, "web-data")+"/index.html")
30         s = fp.read()
31         fp.close()
32         return http.Response(responsecode.OK, {'Content-type': http_headers.MimeType('text', 'html')},stream=s)
33     def locateChild(self, request, segments):
34         print "[WebIf]",request.remoteAddr.host,request.method,request.path,request.args
35         return resource.Resource.locateChild(self, request, segments)