How to deploy cherrypy on pythonanywhere.com

I have a python application developed on Flask. Everything works fine offline, I also successfully used the CherryPy program. Now I'm trying to deploy them to www.pythonanywhere.com.

Here is deploy.py, which I use to deploy Flask application 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" application on pythonanywhere.com. Here's the configuration file (username_pythonanywhere_com_wsgi.py):

import sys

path = '/home/username/appname'
if path not in sys.path:
    sys.path.append(path)

import deploy

deploy.initiate()

Now I'm sure that it "almost worked" because in the server logs I could see my message "Server started ...".

2013-09-27 09:57:16 +0000 username.pythonanywhere.com - *** Operational MODE: single process ***
Server initiated...

Now the problem is, when I try to view my application username.pyhtonanywhere.com/about, time is running out. I suppose this is caused by the wrong port when starting the CherryPy server (in deploy.py).

- , CherryPy?

+4
1

. - wsgi:

import sys
sys.path = [ <path to your web app> ] + sys.path
from cherrypy._cpwsgi import CPWSGIApp
from cherrypy._cptree import Application

from <your_web_app> import <your web app class> 
config_path = '<path to your cherrypy config>'
application = CPWSGIApp(
    Application(<your web app class>(), '', config = config_path)

, < > s.

+2

All Articles