Friday, 27 September 2013

How to deploy CherryPy on pythonanywhere.com

How to deploy CherryPy on pythonanywhere.com

I have a python app developed on Flask. Everything works fine offline, I
tried deploying on CherryPy successfully too. Now, I'm trying to deploy
the same on www.pythonanywhere.com.
Here's the deploy.py I use for deploying the Flask app on CherryPy
from cherrypy import wsgiserver
from appname import app
def initiate():
app_list = wsgiserver.WSGIPathInfoDispatcher({'/appname': app})
server = wsgiserver.CherryPyWSGIServer(
('http://username.pythonanywhere.com/'), app_list)
try:
server.start()
except KeyboardInterrupt:
server.stop()
print "Server initiated..."
initiate()
print "Ended"
I created a "manual configuration" app on pythonanywhere.com. Here's the
configuration file (username_pythonanywhere_com_wsgi.py):
import sys
path = '/home/username/muplan'
if path not in sys.path:
sys.path.append(path)
import deploy
deploy.initiate()
Now I'm pretty sure that it "almost worked", because in the server logs I
could see my "Server initiated..." message.
2013-09-27 09:57:16 +0000 username.pythonanywhere.com - *** Operational
MODE: single process ***
Server initiated...
Now the problem, when I try to view my app
username.pyhtonanywhere.com/about, it times out. This I believe is caused
due to incorrect port given while starting the CherryPy server (in
deploy.py).
Could anyone please tell how I can properly initiate the CherryPy server?

No comments:

Post a Comment