我有一个带有视图的令人毛骨悚然的文件:
from app import app
from flask import request
inspection_handler = None
data_handler = None
repeat_handler = None
@app.route(START_URL + 'inspection/', methods=['GET'])
def inspection():
return inspection_handler.update(request)
@app.route(START_URL + 'data/', methods=['GET'])
def data():
return data_handler.update(request)
@app.route(START_URL + 'repeat/', methods=['GET'])
def repeat():
return repeat_handler.update(request)
另一个模块的代码如下:
from app.handlers.data.data_handler import DataHandler
import app.views.monitoring as monitoring
monitoring.data_handler = DataHandler()
我认为我可以真正改进第一个模块,但我不知道如何正确完成。你能救我吗?
答案 0 :(得分:2)
看一下烧瓶blueprints,并按照建议Flask - Structuring Large Apps
scope.selectResult = function (selected) {
scope.selection = selected;
scope.showResults = false;
scope.productSelected({selected: selected}); // add this
};