pythonamazon-elastic-beanstalkbottle

Can't get bottle to run on Elastic Beanstalk


I've got a website written in bottle and I'd like to deploy it via Amazon's Elastic Beanstalk. I followed the tutorial for deploying flask which I hoped would be similar. I tried to adapt the instructions to bottle by making the requirements.txt this:

bottle==0.11.6

and replaced the basic flask version of the application.py file with this:

from bottle import route, run
@route('/')
def hello():
    return "Hello World!"
run(host='0.0.0.0', debug=True)

I updated to this version as instructed in the tutorial, and when I wrote eb status it says it's green, but when I go to the URL nothing loads. It just hangs there. I tried the run() method at the end as it is shown above and also how it is written in the bottle hello world application (ie run(host='localhost', port=8080, debug=True)) and neither seemed to work. I also tried both @route('/hello') as well as the @route('/').

I went and did it with flask instead (ie exactly like the Amazon tutorial says) and it worked fine. Does that mean I can't use bottle with elastic beanstalk? Or is there something I can do to make it work?

Thanks a lot, Alex

EDIT: With aychedee's help, I eventually got it to work using the following application file:

from bottle import route, run, default_app
application = default_app()
@route('/')
def hello():
    return "Hello bottle World!"

if __name__ == '__main__':
    application.run(host='0.0.0.0', debug=True)

Solution

  • Is it possible that the WSGI server is looking for application variable inside application.py? That's how I understand it works for Flask.

    application = bottle.default_app()
    

    The application variable here is a WSGI application as specified in PEP 333. It's a callable that takes the environment and a start_response function. So the Flask, and Bottle WSGI application have exactly the same interface.

    Possibly... But then I'm confused as to why you need that and the call to run.