Created
January 10, 2017 18:00
-
-
Save derwolfe/56af7e1405cb811fd36e560cfd635c94 to your computer and use it in GitHub Desktop.
example of twisted web
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet import reactor | |
from twisted.web.server import Site | |
from twisted.web.resource import Resource | |
class Page(Resource): | |
def render_GET(self, request): | |
return "hi".encode('utf-8') | |
if __name__ == '__main__': | |
root = Resource() | |
root.putChild(b"", Page()) | |
factory = Site(root) | |
reactor.listenTCP(8888, factory) # @UndefinedVariable | |
reactor.run() # @UndefinedVariable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment