Twisted Web is a web application server written in pure Python, with APIs at multiple levels of abstraction to facilitate different kinds of web programming. The most useful for web application designers is Web Widgets, a high-level class-and-template oriented system. There is also the Resource system, which Web Widgets is built on.
![]() |
Resources are the lowest-level abstraction for applications in the Twisted web
server. Each Resource is a 1:1 mapping with a path that is requested: you can
think of a Resource as a single "page" to be rendered. The interface for making
Resources is very simple; they must have a method named render
which takes a single argument, which is the Request object (an instance of
twisted.web.server.Request
). This render method must return a
string, which will be returned to the web browser making the
request. Alternatively, they can return a special constant,
twisted.web.server.NOT_DONE_YET
, which tells the web server not to
close the connection; you must then use request.write(data)
to
render the page, and call request.finish()
whenever you're
done. There is more information about developing software with Resources in the
Resources, CGIs, Static Content, and Linking
document.
Web Widgets are an added layer of abstraction of Resources -- they're much nicer for most sorts of web applications. For more information on Widgets, see Introducing Web Widgets.