Some of the information here may be outdated, please check the book instead
[edit]

Video

Here is a video by CJ.

Instructions

(by coconutrandom)

You should have Putty by now, right? If not by all means get it form here You also need Firefox and Switchproxy.

1) log into your control panel and make your domain name

2)go to app and add a type "Custom Install script", click "View/hide script" and paste this:

#!/bin/env python2.4
import random
import sys

from webfaction.api import *

def create():
    # Create application.
    app = api.create_app(app_name, 'custom_app_with_port')

    api.system((
      # Download web2py.
      'wget -q http://mdp.cti.depaul.edu/examples/static/web2py_src.zip;'
      'unzip -q web2py_src.zip;'

      'mv web2py/* .;'
       'python2.5 web2py.py > /dev/null 2>&1;'

       # Cleanup
       'rm web2py_src.zip;'
       'rmdir web2py/;'
    ))

    # Create start_web2py.py.
    start_web2py = """#!/bin/env python2.5

from gluon.main import HttpServer
HttpServer(port=%(port)s,password="<recycle>").start()

""" % app
    api.write_file('start_web2py.py', start_web2py)

    # Create cron job.
    api.create_cronjob('*/%s * * * * %s' % (1, cron_job))

    print app['id']

def delete():
    # Stop web2py.
    cmd = (
        'cd %s/webapps/%s/;'
        'ls httpserver.pid > /dev/null 2>&1 && kill `cat httpserver.pid` > /dev/null '
        '2>&1;'
    )
    api.system(cmd % (api.account['home_dir'], app_name))

    # Delete application and cron job.
    api.delete_app(app_name)
    api.delete_cronjob(cron_job)

if __name__ == '__main__':
    action, username, password, server, app_name, autostart,
    extra_info = sys.argv[1:]

    api = API(username, password, server)

    cron_job = (
      'cd %s/webapps/%s/;'
      'ls httpserver.pid > /dev/null 2>&1 && ps -p `cat httpserver.pid` > /dev/null '
      '2>&1 || /usr/local/bin/python2.5 start_web2py.py > /dev/null 2>&1 &'
    ) % (api.account['home_dir'], app_name)

    try:
        locals()[action]()
    except APIError, e:
        print e.message
        sys.exit()

3) Move your local password file, parameters_XXXX.py, into the web2py folder, replace XXXX with the port number.

4) go to Sites, add TWO new sites, one with http and one https. Both with your newly created App. They will need different names, but I just append an _s to the name of the https one.

5) Open Putty and type in your server name for a ssh connection, then under Connection > SSH > Tunnels add a Dynamic Port with the port of your newly created App.

6) Go back to Sessions and type a name for this session and Save it.

7) Connect!

7) In SwitchProxy go to Manage > Add > Standard type in SOCKS Proxy 127.0.0.1 and your App port, IMPORTANT: Make sure you delete "localhost, 127.0.0.1" from "No Proxy for" on the bottom.

8) Give it a label and Ok and select it to use

9) Now goto http://127.0.0.1:[YourAppPort]/

10) Profit!!

© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by web2py - design derived from a theme by the earlybird
The content of this book is released under the Artistic License 2.0 - Modified content cannot be reproduced.