Bottle + WebSocket
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: is it possible to host a normal Bottle application and a WebSocket one (example: https://github.com/defnull/bottle/blob/master/docs/async.rst ) in the same application (same port)? So that /ws will go to WebSocket handler and all other will be normally routed to other bottle handlers. 回答1: It sure is. The server: #!/usr/bin/python import json from bottle import route, run, request, abort, Bottle ,static_file from pymongo import Connection from gevent import monkey; monkey.patch_all() from time import sleep app = Bottle() @app.route('