SQLite runs in memory, and backs up its data store in files on disk. While this strategy works well for development, Heroku’s Cedar stack has an ephemeral filesystem. You can write to it, and you can read from it, but the contents will be cleared periodically. If you were to use SQLite on Heroku, you would lose your entire database at least once every 24 hours.
意思是 SQLite 在記憶體運作,每隔一段時間 Heroku 就會把它清除
Even if Heroku’s disks were persistent running SQLite would still not be a good fit. Since SQLite does not run as a service, each dyno would run a separate running copy. Each of these copies need their own disk backed store. This would mean that each dyno powering your app would have a different set of data since the disks are not synchronized.
老實說這一段我不懂,但看到一些關鍵字說會發生每個 dyno (這啥)都有不同的 data set 的情形發生
if __name__ == "__main__": # 當這份程式被作為主程式執行時 app.run(debug=Ture) # 執行app,debug=True會讓app處於監聽狀態
接著我們建立根路徑
1 2 3
@app.route('/') # Decorator。 在這個路徑下接收到 request (預設為GET) 的話要做以下的事 defindex(): return"Hello world from Flask"
目前整個程式非常單純 就是引入flask後啟動它 並設定當根路徑獲得GET請求時要回傳什麼資訊
接下來我們回到 terminal 執行 python app.py 便能開啟API並等待請求
1 2 3 4 5
FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning. warnings.warn(FSADeprecationWarning( * Debugger is active! * Debugger PIN: 124-333-105 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)