0
在Flask路由開始工作之前,我需要調用函數。在哪裏我應該把功能,以使其在服務啓動時被稱爲。我所做的:如何在啓動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
你的解決方案有什麼問題? –
請詳細介紹一下。 – joshlsullivan