简体   繁体   中英

Change app base in bottle to tornado

My team has developed a website using the bottle as a web service. The issue is that the application has grown, and the simplicity of the bottle is not getting support. What was once simple is getting complicated.

So we decided to change to tornado. The problem is that we do not know how much of code in bottle will have to change to tornado.

So here is the question:

  • in the experience of you guys is easy to make this transition from bottle to tornado?
  • It is necessary to change a lot of code?
  • Or you can merge the two?

When my bottle application's load started to create problems, I found using tornado as the underlying web server is a great solution. You can use bottle on top of tornado. Keep all your bottle code, and then tell the tornado server to run it something like this:

from bottle import Bottle, get
import tornado.wsgi
import tornado.httpserver
import tornado.ioloop

app = Bottle()

@app.get('/')
    return 'my great web page'

if __name__ == "__main__":
    container = tornado.wsgi.WSGIContainer(app)
    server = tornado.httpserver.HTTPServer(container)
    server.listen(port=80)
    tornado.ioloop.IOLoop.instance().start()

Nothing in my bottle app had to change except how the server was launched. Of course, this example is a very simple case.

PS I realize this is a necro-post, but hey!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM