简体   繁体   English

将瓶子中的应用程序基础更改为龙卷风

[英]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.当我的 Bottle 应用程序的负载开始产生问题时,我发现使用 Tornado 作为底层 Web 服务器是一个很好的解决方案。 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:保留所有的 Bottle 代码,然后告诉 Tornado 服务器像这样运行它:

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.除了服务器的启动方式之外,我的 Bottle 应用程序中的任何内容都不必更改。 Of course, this example is a very simple case.当然,这个例子是一个非常简单的案例。

PS I realize this is a necro-post, but hey! PS我意识到这是一个死灵帖,但是嘿!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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