This page is located at /static/zoo-index.html

This template project allows to run Python applications over FastCGI or HTTP using WSGI or generic application workers for backend.

Helicon Zoo is designed to run multiple environments on a single server and all application dependencies are installed into the application's web site directory. This application template is configured to use virtualenv. There is a web console that you can use to run console commands to the virtualenv of this application. Please use this console to run all Python commands on your application, like pip install, django-admin.py, etc. If you use Windows console to run commands you may be actually calling quite different instance or version of Python (depends on your system set up) and installing modules in locations not related to this application at all.

Click on this link to open web console. The web console will only work for local or authenticated requests and external access is restricted for security reasons. You can enable remote access to web console by setting up any authentication method for /console/ directory of the web site.

This template is configured by default to run Python 2.7 WSGI applications using FastCGI protocol. Please review web.config file for more details.

The deploy.py script in the root folder is a sample deploy script. It installs virtualenv and requirements (if any). When execution of this script is completed Helicon Zoo will rename this file to deploy_done.py to prevent further execution. Rename it to deploy.py if you need to start deployment process again. This script is useful when you deploy application to production server running Helicon Zoo and need to execute database migrations, modules updates, etc. There are some commented out examples of common tasks in this script. You can read more about deployment scripts in Helicon Zoo documentation.

Below please find step-by-step instructions to run some common Python configurations:

Contents

Creating Django project

  1. Open web console and type:
    pip install django

    This will install latest version of Django into site virtual environment. To install other version of Django you can use:

    pip install django==1.4.5
  2. Run "django-admin.py" command to start new django project:
    django-admin.py startproject project
  3. Update web.config:
    • Comment line:
      <add name="WSGI_APP" value="welcome.application" />
    • Uncomment line with DJANGO_SETTINGS_MODULE:
      <add name="DJANGO_SETTINGS_MODULE" value="project.settings" />

Running existing Django project

  1. Copy your existing django project folder to site root. Suppose you project named as "myproject1". Do not overwrite web.config file provided with this template project.
  2. Modify web.config as follows:
    • Update PYTHONPATH environment variable with your project folder name. Change from
      <add name="PYTHONPATH" value="...;%APPL_PHYSICAL_PATH%\project" />
      to
      <add name="PYTHONPATH" value="...;%APPL_PHYSICAL_PATH%\myproject1" />
    • Comment line:
      <add name="WSGI_APP" value="welcome.application" />
    • Uncomment and update line with DJANGO_SETTINGS_MODULE with your project settings. If your settings.py is in your project root folder , then the value should be:
      <add name="DJANGO_SETTINGS_MODULE" value="settings" />

Creating generic WSGI project

  1. Create wsgi.py file with the following example content:
    def application(environ, start_response):
        """WSGI Application"""
        start_response('200 OK', [('Content-type','text/html')])
        yield '<h2>WSGI environment variables</h2>\n<pre><code>'
        sorted_envs = environ.keys()[:]
        sorted_envs.sort()
        for k in sorted_envs:
            yield '{0:<24}: {1}\n'.format(k, environ[k])
        yield '</code></pre>'
  2. Modify web.config:
    • Change WSGI_APP environment variable from
      <add name="WSGI_APP" value="welcome.application" />
      to
      <add name="WSGI_APP" value="wsgi.application" />

Running existing WSGI project

  1. Copy your existing WSGI project folder to site root. Suppose you project named as "mywsgiproject". Do not overwrite web.config file provided with this template project.
  2. Modify web.config as follows:
    • Update PYTHONPATH environment variable with your project folder name. Change
      <add name="PYTHONPATH" value="...;%APPL_PHYSICAL_PATH%\project" />
      to
      <add name="PYTHONPATH" value="...;%APPL_PHYSICAL_PATH%\mywsgiproject" />
    • update line with WSGI_APP with your project settings. For example if your file with wsgi application is in mywsgiproject/server, then the value should be:
      <add name="WSGI_APP" value="server.application" />

Running WSGI project via Twisted

  1. Copy your existing WSGI project folder to site root. Suppose you project named as "mywsgiproject". Do not overwrite web.config file provided with this template project.
  2. Modify web.config as follows:
    • Update PYTHONPATH environment variable with your project folder name. Change
      <add name="PYTHONPATH" value="...;%APPL_PHYSICAL_PATH%\project" />
      to
      <add name="PYTHONPATH" value="...;%APPL_PHYSICAL_PATH%\mywsgiproject" />
    • update line with WSGI_APP with your project settings. For example if your file with wsgi application is in mywsgiproject/wsgi.py, then the value should be:
      <add name="WSGI_APP" value="wsgi.application" />
    • Comment handler mappings with scriptProcessor="python.2.7.wsgi"
    • Uncomment handler mappings with scriptProcessor="python.2.7.twisted"
      <!-- HTTP backend (Twisted) over http -->
      <add name="python.project#x86" scriptProcessor="python.2.7.twisted"
           path="*" verb="*" modules="HeliconZoo_x86"
           preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" />
      <add name="python.project#x64" scriptProcessor="python.2.7.twisted"
           path="*" verb="*" modules="HeliconZoo_x64"
           preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" />

Creating Tornado project

  1. Open web console and type:
    pip install tornado
    This will install latest version of Tornado
  2. Create server.py file with the following content:
    import tornado.ioloop
    import tornado.web
    
    from tornado.options import define, options
    
    define("port", default=8888, help="run on the given port", type=int)
    
    class MainHandler(tornado.web.RequestHandler):
        def get(self):
            self.write("Hello, world")
    
    application = tornado.web.Application([
        (r".*", MainHandler),
    ])
    
    if __name__ == "__main__":
        tornado.options.parse_command_line()
        application.listen(options.port)
        tornado.ioloop.IOLoop.instance().start()
  3. Update web.config:
    • Comment line:
      <add name="WSGI_APP" value="welcome.application" />
    • Uncomment line:
      <add name="APP_WORKER" value="server.py" />
    • Comment handler mappings with scriptProcessor="python.2.7.wsgi"
    • Uncomment handler mappings with scriptProcessor="python.2.7.http"
      <!-- HTTP backend (Tornado) over http -->
      <add name="python.project#x86" scriptProcessor="python.2.7.http"
           path="*" verb="*" modules="HeliconZoo_x86"
           preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" />
      <add name="python.project#x64" scriptProcessor="python.2.7.http"
           path="*" verb="*" modules="HeliconZoo_x64"
           preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" />

Running existing Tornado project

  1. Open web console and type:
    pip install tornado
    This will install latest version of Tornado
  2. Copy your existing tornado project folder to site root. Suppose you project named as "mytornadoproject".
  3. Fix web.config as follows:
    • Update PYTHONPATH environment variable with your project folder name. Edit
      <add name="PYTHONPATH" value="...;%APPL_PHYSICAL_PATH%\project" />
      to
      <add name="PYTHONPATH" value="...;%APPL_PHYSICAL_PATH%\mytornadoproject" />
    • Comment line:
      <add name="WSGI_APP" value="welcome.application" />
    • Uncomment and update line with APP_WORKER with your project start file. If your project start file is in mytornadoproject/server.py, then the value should be:
      <add name="APP_WORKER" value="mytornadoproject/server.py" />
    • Comment handler mappings with scriptProcessor="python.2.7.wsgi"
    • Uncomment handler mappings for http applications:
      <!-- HTTP backend (Tornado) over http -->
      <add name="python.project#x86" scriptProcessor="python.2.7.http"
           path="*" verb="*" modules="HeliconZoo_x86"
           preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" />
      <add name="python.project#x64" scriptProcessor="python.2.7.http"
           path="*" verb="*" modules="HeliconZoo_x64"
           preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" />