Python 2.7 利用CherryPy作为Web服务器进行flask应用

Python 2.7 利用CherryPy作为Web服务器进行flask应用,python-2.7,flask,cherrypy,Python 2.7,Flask,Cherrypy,我有一个简单的烧瓶应用程序,它运行得非常好。我一直在独立于主桌面应用程序开发它,我想将flask应用程序“插入”到主应用程序中。我还想使用cherrypy作为Web服务器,因为flask附带的默认Web服务器尚未准备好生产。我不知道如何让这两个一起工作。我的flask应用程序代码如下所示 from flask import Flask, render_template,send_from_directory from scripts_data import test_data from sche

我有一个简单的烧瓶应用程序,它运行得非常好。我一直在独立于主桌面应用程序开发它,我想将flask应用程序“插入”到主应用程序中。我还想使用cherrypy作为Web服务器,因为flask附带的默认Web服务器尚未准备好生产。我不知道如何让这两个一起工作。我的flask应用程序代码如下所示

from flask import Flask, render_template,send_from_directory
from scripts_data import test_data
from schedule_data import scheduledata
import os

app=Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/scripts')
def scripts():
    test_data=t_data()
    return render_template('scripts.html',data_scripts=test_data)

@app.route('/sch')
def schedules():
    data_schedule=s_data()
    return render_template('schedules.html',table_data=data_schedule)

if __name__=='__main__':
    app.run(debug=True)
所以很明显,由于我想集成到主应用程序中,我不能使用app.run。不清楚如何将flask Web服务器替换为Cherrypy Web服务器

我已经看过了

类设置\u Web服务器(对象):
@附件路线(“/”) def hello(): 返回“你好,世界!”

但是当我启动Web服务器并访问该站点(0.0.0.0:5000)时,我得到了404? 我没有得到404,因为它只有一个烧瓶。我所要做的就是将flask内置Web服务器替换为cherrpy Web服务器。我不想将cherrypy用于其他任何事情,因为Flask将是框架

有什么建议吗?我在Windows上使用python 2.7

from flask import Flask
import cherrypy

app = Flask(__name__)
app.debug = True
def run_server():

    # Mount the WSGI callable object (app) on the root directory
    cherrypy.tree.graft(app, '/')

    # Set the configuration of the web server
    cherrypy.config.update({
        'engine.autoreload_on': True,
        'log.screen': True,
        'server.socket_port': 5000,
        'server.socket_host': '0.0.0.0'
    })

    # Start the CherryPy WSGI web server
    cherrypy.engine.start()
    cherrypy.engine.block()


Class start_it_all(object)
import setup_webserver

        setup_webserver.run_server()