Deploying on PythonAnywhere

  1. PythonAnywhere

PythonAnywhere is the simplest way to deploy web2py applications.

PythonAnywhere is a Python development and hosting environment that displays in your web browser and runs on cloud servers. They are already set up with everything you need to run Python and they support web2py specifically. In our experience PythonAnywhere is easy to use, fast, and powerful. They also provide MySQL databases, python shells and Dropbox integration. Professional hosting is available if the free basic one is not enough for you.

In order to use PythonAnywhere you need to create an account, login, then use the provided web Dashboard to add a new Web App of type web2py.

image

image

The interface also ask you for an administrative password.

image

The web2py folder will be created in your user folder.

Alternatively, you can also use the web based BASH shell to install web2py as you normally do:

  1. wget http://www.web2py.com/examples/static/web2py_src.zip
  2. unzip web2py_src.zip

Always from the shell you should create an admin password for later use:

  1. python -c "from gluon.main import save_password; save_password(raw_input('admin password: '), 443)"

Then visit the “Web” panel using the web interface and edit the “/var/www/_pythonanywhere_com_wsgi.py” file. This is the entry point for your program (in our case web2py) and, as you may guess, it is based on the WSGI protocol.

Edit the “/var/www/_pythonanywhere_com_wsgi.py” file and write in it:

  1. import sys
  2. path = '/home/<username>/web2py'
  3. if path not in sys.path: sys.path.append(path)
  4. from wsgihandler import application # the web2py handler

Here ““ is your PythonAnywhere username.

After you’ve installed web2py, notice that you do not need to start or configure a web server. PythonAnywhere provides one and it is reloaded when you edit the above config file. or press the “Reload web app” button on the Dashboard. Everyone can immediately access it at the url:

  1. http://yourusername.pythonanywhere.com/

They also provide a secure version of the site, and you’re forced to use it for using the web2py Administrative interface at:

  1. https://yourusername.pythonanywhere.com/admin/default/index

We thank the PythonAnywhere team for their help and support.