NiceGUI: crea una aplicación web en Python sin escribir JavaScript
Si sabes Python pero el frontend te frena, NiceGUI es una de las mejores noticias de los últimos años: te permite construir aplicaciones web completas —con botones, formularios, gráficos y navegación— usando solo Python. ¿Qué es NiceGUI? Es un framework construido sobre FastAPI (backend) y Quasar/Vue (frontend). Tú escribes Python; NiceGUI genera la interfaz en el navegador y mantiene…
NiceGUI is a Python framework that simplifies web application development by eliminating the need for JavaScript. It is built on top of FastAPI (backend) and Quasar/Vue (frontend). With NiceGUI, you can create complete web applications featuring buttons, forms, charts, and navigation using only Python. You do not need to write HTML, CSS, or JavaScript to get started.
To create a simple app, you can write just four lines of code:
```python
from nicegui import ui
ui.button("Say Hello", on_click=lambda: ui.notify("¡Hola!"))
ui.run()
```
The UI structure is expressed using context managers, which mirror the nesting of elements. Here's an example of a card with a login form:
```python
with ui.card():
ui.label("Login", classes="text-xl font-bold")
username = ui.input("Username")
password = ui.input("Password", password=True)
ui.button("Enter", on_click=lambda: login(username.value, password.value))
```
Adding reactive state, forms, tables, or routes is just as straightforward. NiceGUI is ideal for MVPs, prototypes, internal tools, and demos of AI models or scripts that require an interface. However, it may not be the best choice for SEO-critical sites or applications where server-side rendering is preferred.
NiceGUI runs in the client, so it's best suited for internal tools, dashboards, and applications where performance and ease of deployment are key. The app is deployed like any FastAPI/Uvicorn application, typically behind nginx with systemd. To serve the static files, nginx is used, and in production, `ui.run(show=False)` is employed to avoid opening a browser on the server.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.