浏览代码

add startup and shutdown handlers to existing FastAPI app

Falko Schindler 1 年之前
父节点
当前提交
ab67f90799
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      nicegui/ui_run_with.py

+ 3 - 0
nicegui/ui_run_with.py

@@ -5,6 +5,7 @@ from fastapi import FastAPI
 
 from . import core, storage
 from .language import Language
+from .nicegui import _shutdown, _startup
 
 
 def run_with(
@@ -52,3 +53,5 @@ def run_with(
     storage.set_storage_secret(storage_secret)
 
     app.mount(mount_path, core.app)
+    app.on_event('startup')(_startup)
+    app.on_event('shutdown')(_shutdown)