Web.py on dotcloud with wsgi

I am trying to deploy my web.py application in dotcloud but cannot figure out how to do this.

I studied this tutorial well: http://docs.dotcloud.com/static/tutorials/firststeps/

And then I looked at http://docs.dotcloud.com/static/components/python/ ...

The python service can contain any python web application that is compliant with the WSGI standard.

This includes all modern Python framework websites: Django, Pylons, web.py, web2py, etc.

...

python works with Nginx + uWSGI, managed by a supervisor. Static assets are served directly by Nginx, for better performance.

...

DotCloud relies on well-established tools and conventions to build your application. It should be trivial to adapt any application to work in DotCloud.

...

When deploying the application, DotCloud searches for a file named wsgi.py. To do, be sure to create this file in the root of your application directory.


Googling "web.py wsgi" leads to http://webpy.org/install , which has a rather confusing array of instructions. I tried a number of suggestions on the page, but could not get anything to work.

The most promising prospect seemed to be to create a wsgi.py file, for example:

import web urls = ( '/(.*)', 'hello' ) class hello: def GET(self, name): if not name: name = 'World' return 'Hello, ' + name + '!' app = web.application(urls, globals(), autoreload=False) application = app.wsgifunc() 

I also created an empty __init__.py next to it.

Then I did:

 dotcloud create jca_hello.py dotcloud deploy -t python jca_hello.www dotcloud push jca_hello.www . 

But now, when I go to http://www.jca_hello.dotcloud.com/ , I see the following:

UWSGI error

Wsgi application not found

Any ideas?

+8
python web.py wsgi
source share
1 answer

I am a friend of web.py user and I work in DotCloud, by the way :-)

We use uWSGI to launch your WSGI application. The fact is that uWSGI is looking for a variable called "application".

Here is what I usually do:

 app = web.application(urls, globals()) if __name__ == '__main__': app.run() else: web.config.debug = False application = app.wsgifunc() 

So, you can continue to use the application on your local computer:

 $ python ./wsgi.py 

And click it on production (of course, on DotCloud;) with debugging mode disabled.

Here is your wsgi.py file fixed:

 import web urls = ( '/(.*)', 'Hello' ) class Hello(object): def GET(self, name): if not name: name = 'World' return 'Hello, ' + name + '!' app = web.application(urls, globals()) if __name__ == '__main__': app.run() else: web.config.debug = False application = app.wsgifunc() 

Beware of using your wsgi.py correctly in your approach.

Also make sure you have a file named "requirements.txt" in your consent, containing:

 web.py 

In the meantime, feel free to contact DotCloud support if you have any deployment problems.

+13
source share

All Articles