Forums

CherryPy or Paste to serve Bottle apps

For running bottle apps on a local machine, one uses bottle.run().

bottle.run() can take arguments such as: bottle.run(host='localhost', port=8080, server='wsgiref') etc.

The arguments above also happen to be defaults.

However, I would like to use CherryPy or paste to serve my app instead of wsgiref.

[ EDIT: bottle supports the setting server='cherrypy' or server='paste'. ]

I have no idea about how to accomplish the same at pythonanywhere.com.

Any suggestions will be helpful. Thanks.

Hi @pymesh, we serve your application for you using uWSGI workers which handle the WSGI protocol. It expects a variable called "application", which implements the WSGI protocol, to be available in the WSGI file in /var/www (you'll find a link on the Web tab). So, if you can figure out how to get CherryPy or Paste to wrap your bottle app and spit out a WSGI app, then you're good to go.

With that said, are you looking to switch out to CherryPy/Paste because they support multithreading? That wouldn't work, because we don't support multithreading...

Hi i want to run my bottlepy app in mysecretary.pythonanywhere.com, Currently my code to run bottle is bottle.run(host="localhost", port="8080"). For running is there any changes should i have made in host or port variables.

You don't need to do bottle.run at all. That starts bottle up listening on a particular port, which wouldn't work on PythonAnywhere.

The way PythonAnywhere works is that we provide a uWSGI container for your app to run in. For the site mysecretary.pythonanywhere.com, the configuration for this would be stored in your private file storage, as mysecretary_pythonanywhere_com_wsgi.py. That file needs to export a variable called application, which you can get from bottle by calling bottle.default_app.

I see you have an error on your site at the moment, and from the look of our logs it looks like all of the above is configured properly, and the issue is that it's being caused by your code calling bottle.run somewhere. If you remove that line then it should work.

If you'd like me to take a look at your files, then I can -- I just need your permission in a forum post here.