diff --git a/Adafruit_Video_Looper/webui.py b/Adafruit_Video_Looper/webui.py index bbb6d23..4885b9d 100644 --- a/Adafruit_Video_Looper/webui.py +++ b/Adafruit_Video_Looper/webui.py @@ -26,9 +26,6 @@ with app.app_context(): app.iniconfig.read(config_path) # Build a sample db on the fly, if one does not exist yet. app_dir = os.path.realpath(os.path.dirname(__file__)) -database_path = os.path.join(app_dir, app.config['DATABASE_FILE']) -if not os.path.exists(database_path): - build_sample_db() print app.config["SECURITY_POST_LOGIN_VIEW"] # Define models @@ -170,7 +167,7 @@ class VideoAdmin(fileadmin.FileAdmin): if not op.exists(path): os.makedirs(path) return path - + @property def base_dir(self): return app.iniconfig.get("directory", "path") @@ -186,7 +183,7 @@ class VideoAdmin(fileadmin.FileAdmin): def on_edit_file(self, *args, **kwargs): self.update_base() - + def on_file_delete(self, *args, **kwargs): self.update_base() @@ -198,6 +195,9 @@ videoadmin = VideoAdmin() admin.add_view(videoadmin) if __name__ == '__main__': + database_path = os.path.join(app_dir, app.config['DATABASE_FILE']) + if not os.path.exists(database_path): + build_sample_db() app.run(host=app.config.get("HOST", "localhost"), port=app.config.get("PORT", 5000), debug=True)