Forums

two cherrypy apps side by side

Hello

I started from the demo wsgi file for cherrypy but wanted to know how to mount two cherrypy app (or Python classes) to two differents mount point ?

import sys
sys.stdout = sys.stderr

import atexit
import threading
import cherrypy

cherrypy.config.update({'environment': 'embedded'})

cherrypy.engine.start()
atexit.register(cherrypy.engine.stop)

class App_alpha():
    @cherrypy.expose
    def index(self, * arg_pos, ** arg_nam):
        return 'class App_alpha()' + str(arg_pos) + str(arg_nam)

class App_beta():
    @cherrypy.expose
    def index(self, * arg_pos, ** arg_nam):
        return 'class App_beta()' + str(arg_pos) + str(arg_nam)

application = cherrypy.Application(App_alpha(), script_name='/alpha', config=None)
application = cherrypy.Application(App_beta(), script_name='/beta', config=None)

I would like to access the App_alpha() class from yoochan.pythonanywhere.com/alpha/index and the App_beta() class from yoochan.pythonanywhere.com/beta/index.

This, obviously does not behave as expected.

/beta/index works, /alpha/index returns a weird 404 Not Found The path '/betaa/index' was not found. /betaa ?

Hi there,

I don't know much about CherryPy, but I know it tends to try to run its own web server. Since we actually do that for you on PythonAnywhere, you should configure it to run as a "pure" wsgi application, with the assumption that we will do the serving for you.

This whole page looks interesting, but we're using uwsgi so this part may be the most relevant.