Can NiceGUI integrate directly with Starlette? #4381
-
QuestionThe examples provided allow running NiceGUI alongside an existing FastAPI app. Since FastAPI is itself built on top of Starlette, can NiceGUI be run alongside an existing Starlette app? |
Beta Was this translation helpful? Give feedback.
Answered by
falkoschindler
Feb 24, 2025
Replies: 1 comment 1 reply
-
Good question, @EntangledLabs! It seems to work nicely: from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route
from nicegui import ui
async def homepage(request):
return JSONResponse({'hello': 'world'})
app = Starlette(debug=True, routes=[Route("/", endpoint=homepage)])
@ui.page("/ui")
def ui_page():
ui.label("Hello world")
ui.run_with(app) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
EntangledLabs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good question, @EntangledLabs!
It seems to work nicely: