evennia.server.webserver¶
This implements resources for Twisted webservers using the WSGI interface of Django. This alleviates the need of running e.g. an Apache server to serve Evennia’s web presence (although you could do that too if desired).
The actual servers are started inside server.py as part of the Evennia application.
(Lots of thanks to http://github.com/clemesha/twisted-wsgi-django for a great example/aid on how to do this.)
-
class
evennia.server.webserver.
LockableThreadPool
(*args, **kwargs)[source]¶ Bases:
twisted.python.threadpool.ThreadPool
Threadpool that can be locked from accepting new requests.
-
__init__
(*args, **kwargs)[source]¶ Create a new threadpool.
@param minthreads: minimum number of threads in the pool @type minthreads: L{int}
@param maxthreads: maximum number of threads in the pool @type maxthreads: L{int}
@param name: The name to give this threadpool; visible in log messages. @type name: native L{str}
-
-
class
evennia.server.webserver.
HTTPChannelWithXForwardedFor
[source]¶ Bases:
twisted.web.http.HTTPChannel
HTTP xforward class
-
class
evennia.server.webserver.
EvenniaReverseProxyResource
(host, port, path, reactor=<twisted.internet.epollreactor.EPollReactor object>)[source]¶ Bases:
twisted.web.proxy.ReverseProxyResource
-
getChild
(path, request)[source]¶ Create and return a proxy resource with the same proxy configuration as this one, except that its path also contains the segment given by path at the end.
- Parameters
path (str) – Url path.
request (Request object) – Incoming request.
- Returns
resource (EvenniaReverseProxyResource) – A proxy resource.
-
-
class
evennia.server.webserver.
DjangoWebRoot
(pool)[source]¶ Bases:
twisted.web.resource.Resource
This creates a web root (/) that Django understands by tweaking the way child instances are recognized.
-
__init__
(pool)[source]¶ Setup the django+twisted resource.
- Parameters
pool (ThreadPool) – The twisted threadpool.
-
-
class
evennia.server.webserver.
Website
(resource, requestFactory=None, *args, **kwargs)[source]¶ Bases:
twisted.web.server.Site
This class will only log http requests if settings.DEBUG is True.
-
noisy
= False¶
-
-
class
evennia.server.webserver.
WSGIWebServer
(pool, *args, **kwargs)[source]¶ Bases:
twisted.application.internet.TCPServer
This is a WSGI webserver. It makes sure to start the threadpool after the service itself started, so as to register correctly with the twisted daemon.
call with WSGIWebServer(threadpool, port, wsgi_resource)
-
class
evennia.server.webserver.
PrivateStaticRoot
(path: str, defaultType: str = 'text/html', ignoredExts: Sequence[str] = (), registry: twisted.web.static.Registry | None = None, allowExt: Literal[0] = 0)[source]¶ Bases:
twisted.web.static.File
This overrides the default static file resource so as to not make the directory listings public (that is, if you go to /media or /static you won’t see an index of all static/media files on the server).