Я хотел бы использовать одну иерархию ресурсов для локальных подключений и другую иерархию ресурсов для всех других подключений. Как бы я пошел по этому поводу?
publicSite = Site(File("/var/www/"))
localhostSite = Site(File("/var/localhost/"))
publicServer = TCPServer(80, publicSite, interface="0.0.0.0")
localhostServer = TCPServer(80, localhostSite, interface="127.0.0.1")
Кажется, вы не можете одновременно прослушивать два разных интерфейса.
Я получаю следующую ошибку:
Traceback (most recent call last):
File "/usr/bin/twistd", line 21, in <module>
run()
File "/usr/lib/python2.5/site-packages/twisted/scripts/twistd.py", line 27, in run
app.run(runApp, ServerOptions)
File "/usr/lib/python2.5/site-packages/twisted/application/app.py", line 379, in run
runApp(config)
File "/usr/lib/python2.5/site-packages/twisted/scripts/twistd.py", line 23, in runApp
_SomeApplicationRunner(config).run()
File "/usr/lib/python2.5/site-packages/twisted/application/app.py", line 158, in run
self.postApplication()
File "/usr/lib/python2.5/site-packages/twisted/scripts/_twistd_unix.py", line 213, in postApplication
startApplication(self.config, self.application)
File "/usr/lib/python2.5/site-packages/twisted/scripts/_twistd_unix.py", line 174, in startApplication
service.IService(application).privilegedStartService()
File "/usr/lib/python2.5/site-packages/twisted/application/service.py", line 228, in privilegedStartService
service.privilegedStartService()
File "/usr/lib/python2.5/site-packages/twisted/application/internet.py", line 68, in privilegedStartService
self._port = self._getPort()
File "/usr/lib/python2.5/site-packages/twisted/application/internet.py", line 86, in _getPort
return getattr(reactor, 'listen'+self.method)(*self.args, **self.kwargs)
File "/usr/lib/python2.5/site-packages/twisted/internet/posixbase.py", line 467, in listenTCP
p.startListening()
File "/usr/lib/python2.5/site-packages/twisted/internet/tcp.py", line 733, in startListening
raise CannotListenError, (self.interface, self.port, le)
twisted.internet.error.CannotListenError: Couldn't listen on 127.0.0.1:80: (98, 'Address already in use').
1