I'm trying to deploy my web.py app on dotcloud, but can't figure out how to do it.
I went through this tutorial fine: http://docs.dotcloud.com/static/tutorials/firststeps/
And then I looked at http://docs.dotcloud.com/static/components/python/ ...
The python service can host any python web application compatible with the WSGI standard.
That includes all modern Python web frameworks: Django, Pylons, web.py, web2py, etc.
...
python runs with Nginx + uWSGI, managed by supervisord. Static assets are served directly by Nginx, for greater performance.
...
DotCloud relies on well-established tools and conventions to build your app. It should be trivial to adapt any application to run on DotCloud.
...
When deploying your app, DotCloud looks for a file called wsgi.py. Make sure to create that file at the root of your application directory.
Googling "web.py wsgi" leads to http://webpy.org/install which has a pretty bewildering array of instructions. I tried a number of suggestions on the page, but couldn't get anything to work.
The most promising prospect seemed to be creating a file called wsgi.py like so:
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/ all I see is:
uWSGI Error
wsgi application not found
Any ideas?
I am fellow user of web.py and I work at DotCloud by the way :-)
We use uWSGI to run your WSGI application. The point is that uWSGI is looking for a variable named "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 both continue to use your app on your local machine:
$ python ./wsgi.py
And push it on production (on DotCloud of course ;) with debug mode disabled.
Here is your wsgi.py file corrected:
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 correctly having your wsgi.py in your approot.
Also make sure that you have a file named "requirements.txt" in your approot containing:
web.py
In the meantime, do not hesitate to contact the DotCloud support if you have any problem with your deployments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With