I'm trying to run klein with twisted, so I can run twisted scripts on different paths (exp: example.com/example1
, example.com/example2
). So I made a simple script:
from klein import run, route, Klein
from twisted.internet import reactor
from twisted.web import proxy, server
from twisted.python import log
@route('/example')
def home(request):
site = server.Site(proxy.ReverseProxyResource('www.example.com', 80, b''))
reactor.listenTCP(80, site)
reactor.run()
run("My_IP_Address", 80)
But whenever I run this script I get an Error: twisted.internet.error.CannotListenError: Couldn't listen on any:80: [Errno 98] Address already in use.
I'm very new to Klein, and I'm not sure how it works, Could anybody tell me what it is I'm doing wrong? thanks!