Skip to content

Instantly share code, notes, and snippets.

@EntityReborn
Created June 1, 2011 20:38
Show Gist options
  • Save EntityReborn/1003265 to your computer and use it in GitHub Desktop.
Save EntityReborn/1003265 to your computer and use it in GitHub Desktop.
from socbot.pluginbase import Base
from twisted.application import internet
from twisted.web import resource, server
class Simple(resource.Resource):
isLeaf = True
def render_GET(self, request):
return "<html><head><title>Ohai2</title></head><body>Hello, world 2!</body></html>"
class Plugin(Base):
def initialize(self, *args, **kwargs):
self.simple = Simple()
self.site = server.Site(self.simple)
self.server = internet.TCPServer(8080, self.site)
self.server.startService()
def disabling(self, *args, **kwargs):
if hasattr(self, "server"):
retn = self.server.stopService()
else:
self.log.error("No SERVER!")
return
return retn
def beforeReload(self, *args, **kwargs):
return self.disabling(*args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment