aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Plugins/web/plugin.py
blob: 1c40293afa1889c778112fe216f8e9a2e1c8eb9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from twisted.internet import reactor
from twisted.web2 import server, http, static
from Plugins.Plugin import PluginDescriptor

def startWebserver():
	toplevel = static.File("/hdd")
	site = server.Site(toplevel)
	
	reactor.listenTCP(80, http.HTTPFactory(site))

def autostart(reason):
	if reason == 0:
		try:
			startWebserver()
		except ImportError:
			print "twisted not available, not starting web services"

def Plugins():
	return PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart)