【发布时间】:2017-10-05 13:04:26
【问题描述】:
我需要在 Flask 路由开始工作之前执行调用功能。我应该在哪里放置函数以使其在服务启动时调用。我做到了:
app = Flask(__name__)
def checkIfDBExists(): # it is my function
if not DBFullPath.exists():
print("Local DB do not exists")
else:
print("DB is exists")
checkIfDBExists()
@app.route("/db", methods=["POST"])
def dbrequest():
pass
【问题讨论】:
-
你的解决方案有什么问题?
-
请提供更多细节。