Changes between Version 13 and Version 14 of TwistedWeb


Ignore:
Timestamp:
09/04/2017 01:00:49 AM (3 months ago)
Author:
Craig Rodrigues
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TwistedWeb

    v13 v14  
    1414Twisted Web is a very simple to set up stand-alone server.  For example, to run a server that serves static content out of the current directory, you can just run this short command line:
    1515{{{
    16 twistd web --path . --port 8080
     16twistd web --path . --port tcp:8080
    1717}}}
    1818To run a WSGI application, it's just as simple:
    1919{{{
    20 twistd web --wsgi my.application.name --port 8080
     20twistd web --wsgi my.application.name --port tcp:8080
    2121}}}
    2222Because Twisted Web is also a Python library with a documented API, you can configure your server entirely using Python.  For example, let's say you have a bunch of directories with names corresponding to each domain you want to serve from your web server.  Here's the configuration file which creates a virtual host configuration serving static content for each domain out of the directory matching its name:
     
    3333This configuration can be run with:
    3434{{{
    35 twistd web --resource-script=virtual.rpy --port 8080
     35twistd web --resource-script=virtual.rpy --port tcp:8080
    3636}}}
    3737Unlike some other simple-to-run Python web servers, Twisted Web is an production-grade server that can be used to deploy real applications.  Among other sites, this web site (twistedmatrix.com) is run entirely via Twisted Web.  Because it's programmable, you can customize your deployment as much or as little as you like, including having your web server run [http://twistedmatrix.com/documents/current/api/twisted.internet.task.LoopingCall.html periodic tasks].  Because it's self-contained and requires no configuration, it's ideal for developing web applications because your production environment can mirror your deployment environment very closely with little effort.