Переглянути джерело

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)