Search code examples
pythonweb2pypythonanywhere

How do I deploy web2py on PythonAnywhere?


How do i get a basic web2py server up and running on PythonAnywhere?


Solution

  • [update - 29/05] We now have a big button on the web tab that will do all this stuff for you. Just click where it says Web2Py, fill in your admin password, and you're good to go.

    Here's the old stuff for historical interest...

    I'm a PythonAnywhere developer. We're not massive web2py experts (yet?) but I've managed to get web2py up and running like this:

    First download and unpack web2py:

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

    Go to the PythonAnywhere "Web" panel and edit your wsgi.py. Add these lines:

    import os
    import sys
    
    path = '/home/my_username/web2py'
    if path not in sys.path:
        sys.path.append(path)
    
    from wsgihandler import application
    

    replacing my_username with your username.

    You will also need to comment out the last two lines in wsgi.py, where we have the default hello world web.py application...

    # comment out these two lines if you want to use another framework
    #app = web.application(urls, globals())
    #application = app.wsgifunc()
    

    Thanks to Juan Martinez for his instructions on this part, which you can view here: http://web2py.pythonanywhere.com/

    then open a Bash console, and cd into the main web2py folder, then run

    python web2py.py --port=80
    

    enter admin password

    press ctrl-c

    (this will generate the parameters_80.py config file)

    then go to your Web panel on PythonAnywhere, click reload web app, and things should work!