返回资讯中心
外部精选
软件工程
#开发者实时流

Nitro – Build static sites in plain Python

Templates are a second language to learn and debug. A Nitro page is a Python function that returns HTML, and the build is a folder you can host anywhere.$ pip install nitro-cli

Hacker News 最新ghstcode2026/10/30 · 18 天前8 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

Templates are a second language to learn and debug. A Nitro page is a Python function that returns HTML, and the build is a folder you can host anywhere.$ pip install nitro-cli

Quickstart

Latestv1.0.17

PackagesSix

RequiresPython 3.9+

TemplatesNone

You writepage.py

from nitro_ui import Body, Div, H1, H2, Paragraph, Section from nitro import Page

FEATURES = [ ("No templates", "Pages are Python functions."), ("No config", "Sensible defaults, zero setup."), ]

def render(): return Page( title="Hello", content=Body( H1("Hello, World!"), Section( *[ Div(H2(name), Paragraph(text), cls="card") for name, text in FEATURES ], cls="features", ), ), )

Nitro buildsindex.html

<!doctype html> <html> <body> <h1>Hello, World!</h1> <section class="features"> <div class="card"> <h2>No templates</h2> <p>Pages are Python functions.</p> </div> <div class="card"> <h2>No config</h2> <p>Sensible defaults, zero setup.</p> </div> </section> </body> </html>

No template language in between.

Six tools. Install one.

Each package stands on its own. Take Nitro UI for HTML inside a Flask app and leave the rest of the toolchain behind.

=Nitro CLI

Build static sites with Python code instead of template engines. Live reload, incremental builds, deploy anywhere.

nitro-cli1.0.17

</>Nitro UI

Create HTML with Python classes instead of strings. Type-safe, autocomplete-friendly, zero dependencies.

nitro-ui1.0.11

{ }Nitro DataStore

Read JSON with dot notation and a chainable query builder. No schema to define, no ORM to learn.

nitro-datastore1.0.5

//Nitro Dispatch

Add plugins to any Python app. Async-ready hooks with priorities and error isolation built in.

nitro-dispatch1.1.0

[x]Nitro Validate

Validate data in one line. 51+ built-in rules, zero dependencies, and pipe-string rules like required|email.

nitro-validator1.0.4

[ ]Nitro Image

Resize, convert, and optimise images with a chainable API. Generate responsive sizes in one call.

nitro-image1.1.1

The modelThree concepts.

No build config and no magic. If you can write a Python function, you can write a page.

page.pydef render(): return Page( title="Hello", content=Body(H1("Hello, World!")), )

1 / 3Pages are functions.

Loops, conditionals, imports, f-strings: everything Python already does, instead of a template dialect that reimplements half of it.

component.pyCard( H2("Welcome"), Paragraph("Get started in seconds."), cls="hero-card" )

2 / 3Components are classes.

Nest them, reuse them, pass data as keyword arguments. A misspelled element is a NameError at build time, not a silently empty div in production.

data.pydata = DataStore.from_file("posts.json")

for post in data.posts: Card(title=post.title)

3 / 3Data is dot notation.

Point it at a JSON file and read data.posts straight off it. No schema to define first, and no chain of dictionary keys to get wrong.

The CLIScaffold, watch, build.

Live reload while you work, incremental builds that skip what hasn't changed, and a plain folder of HTML at the end.

Terminal~/my-site

Commandnitro dev

Port3000

ReloadLive

OutputStatic HTML

Python is all you need.

No webpack. No template languages. No JavaScript required. Just Python functions that return HTML.

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →