How do I deploy web2py on PythonAnywhere?
Asked Answered
E

5

12

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

Erotogenic answered 5/12, 2011 at 13:44 Comment(1)
getting the admin site running is an extra challenge, because HTTPS isn't supported yet - I've included a workaround in my answer...Lovel
L
17

[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!

Lovel answered 5/12, 2011 at 14:25 Comment(1)
There is no app = web.application(urls, globals())Toritorie
K
4

You can also simply run this bash script:

http://pastebin.com/zcA5A89k

admin will be disabled because of no HTTPS unless you bypass it as in the previous post. It will create a security vulnerability.

Kassala answered 5/12, 2011 at 15:17 Comment(1)
Pls explain python -c "from gluon.main import save_password; save_password(raw_input('admin password: '),433)"Toritorie
C
2

Pastebin was down, I retrieved this from the cache.

cd ~
wget -O web2py_srz.zip http://web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
echo "
PATH = '/home/"`whoami`"/web2py'
import os
import sys
sys.stdout = sys.stderr
os.chdir(PATH)
if not './' in sys.path[:1]: sys.path.insert(0,'./')
from gluon.main import wsgibase as application
" > /var/www/wsgi.py
cd web2py
python -c "from gluon.main import save_password; save_password(raw_input('admin  password: '),433)"
Calabria answered 27/3, 2012 at 18:24 Comment(0)
C
1

I have recently summarized my experience with deployment of Web2Py on PythonAnywhere here

Hope it helps NeoToren

Chewning answered 28/3, 2015 at 20:43 Comment(0)
C
0

I'll try to add something new to the discussion. The EASIEST way I've found is to go here when you aren't logged in. This makes it so you don't have to mess around with the terminal:

https://www.pythonanywhere.com/try-web2py

Come up with a domain name, then you'll get redirected to a page showing your login information and created dashboard for that domain. From there just create an account so your app isn't erased after 24 hours. When you sign up, your app has a 3 month expiry date (if you're not paying). I believe this is a new policy. Then simply go to https://appname.pythonanywhere.com/admin and then enter the password you were given and then upload your Web2Py file into the dashboard and then visit the page.

I'm not sure how to upload a Web2Py app on PythonAnywhere for an existing account, but that's the easiest method I've found.

Cilla answered 18/6, 2016 at 21:0 Comment(1)
PythonAnywhere dev here: just to clarify one point -- free accounts keep their web apps forever, but you have to log in and click a button at least once every three months to keep them running. That's to stop our servers from getting clogged up with sites that people set up to try something out but don't want any more. We're happy to keep hosting your site indefinitely if you actually want it :-)Demonstrable

© 2022 - 2024 — McMap. All rights reserved.