conradbez/hstream
关于
Hyper Stream
网站与应用开发可以做什么
- Linear scripts. Inputs return values; each interaction reruns the script top to bottom.
- Components: markdown, text/number inputs, sliders, select boxes, multiselects, checkboxes, buttons, file uploads, screenshots of the page or one element, matplotlib plots, pandas tables. Full list.
- Placeholders: p = hs.placeholder() reserves a spot to fill or overwrite later in the script.
- Navigation: page = hs.nav(["Home", "About"]) and with hs.nav_bar: render a nav bar where you call them (or in a placeholder: with header.nav_bar:).
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文HStream
Turn a Python script into an interactive web app:
from hstream import hs
name = hs.text_input("What's your name?")
hs.markdown(f"Hello, **{name}**!")
Powered by Django + htmx: plain HTML over HTTP, no JavaScript build step, deploys anywhere Django can, with four runtime dependencies. Inspired by Streamlit.
Usage
pip install hstream
hstream init # writes example.py
hstream run example.py # http://127.0.0.1:8000

Features
- Linear scripts. Inputs return values; each interaction reruns the script top to bottom.
- Components: markdown, text/number inputs, sliders, select boxes, multiselects, checkboxes, buttons, file uploads, screenshots of the page or one element, matplotlib plots, pandas tables. Full list.
- Placeholders:
p = hs.placeholder()reserves a spot to fill or overwrite later in the script. - Navigation:
page = hs.nav(["Home", "About"])andwith hs.nav_bar:render a nav bar where you call them (or in a placeholder:with header.nav_bar:). - Your own HTML:
with hs.html("section"):, Pico CSS theming, and@componentfor custom components. - Component packages: other packages can add components to
hsthrough an entry point.pip install "hstream[webawesome]"gives you all 78 Web Awesome components (from hstream import wa, thenwa.input(...); hstream-webawesome);pip install "hstream[3d]"adds clickable 3D viewers (viewer3d.model_viewer,viewer3d.babylon; hstream-3d); write your own. - Agent friendly:
GET /returns the rendered page, and each control'shx-postURL is in the HTML, so another program (or LLM agent) can drive the app with plain HTTP and a cookie jar. - Easy deployment:
hstream deploy app.pywrites a Dockerfile. - No server option:
hstream build app.py --servebuilds a static site that runs in the browser with Pyodide (details).
In the browser (Pyodide)
The same script also runs with no server: hstream build writes a static site
where Pyodide runs your Python in the visitor's browser.
hstream build app.py # writes dist/ (index.html, hstream_browser.js, hstream.zip, app.py)
hstream build app.py --serve # build and serve on http://127.0.0.1:8000, live-reloading edits to app.py
hstream build app.py --static # one self-contained app.html (-o name.html to rename)
hstream build app.py --static --clipboard # copy that HTML to the clipboard instead
The --static file opens straight from disk (double-click it) and can be
emailed or pasted anywhere that takes HTML. Only Pyodide itself comes from its
CDN.
Host dist/ on any static host (GitHub Pages, S3, Netlify), or put it in an
existing page with <iframe src="dist/index.html"></iframe>. hstream boots
Pyodide itself, so you don't need a PyScript <script type="py"> tag (and
that route isn't supported). Pyodide's own packages (numpy, pandas,
matplotlib) load from your imports. Other PyPI packages come from a
requirements.txt next to your script (used automatically), or from
-r humanize / -r other.txt. See
docs/features/browser.md.
See motivation.md for the rationale and architecture.md for how it works. More examples are in demo/ (hstream run demo/nav_bar.py browses them).

Technologies
Big thanks to Streamlit, htmx, Yattag, Pico CSS and Django.
探索相关项目
加载中…