fasthtml-base
FastHTML 核心库 + 项目脚手架。用一条命令生成带前台页面、后台登录、网站信息管理的 FastHTML 站点骨架。
安装(推荐一条命令)
uv tool install fasthtml-base
uv tool 会自动建隔离环境并拉齐 python-fasthtml 等依赖,装完直接就能敲 fasthtml-base,
不需要手动创建虚拟环境,用完也不用清理。
若提示
...\.local\bin is not on your PATH,执行uv tool update-shell后重开终端。
只想临时用一次:
uvx fasthtml-base new MySite
或者用 pip:
pip install fasthtml-base
离线 / 内网分发:在本仓库根目录执行 uv build 生成 wheel,再用本地 wheel 安装:
uv build
uv tool install dist\fasthtml_base-<版本>-py3-none-any.whl
使用
# 在当前目录下创建项目 MySite
fasthtml-base new MySite
# 指定父目录
fasthtml-base new MySite -p D:\Projects
# 显式指定随项目附带的 wheel(离线分发用)
fasthtml-base new MySite --wheel D:\dist\fasthtml_base-<版本>-py3-none-any.whl
# 只生成骨架,不自动安装依赖
fasthtml-base new MySite --no-sync
生成完成后:
cd MySite
uv run python main.py
浏览器打开 http://127.0.0.1:5001。
生成的项目结构
MySite/
├── main.py # 应用入口与路由注册
├── models.py # 数据模型(User / Admin / SiteInfo)
├── db.py # fastlite 数据库连接与初始化
├── pages/ # 页面模块,每个模块导出 ar (APIRouter)
│ ├── home.py
│ ├── about.py
│ ├── admin_login.py
│ ├── admin.py
│ └── siteinfo.py
├── .env.example # SECRET_KEY 示例,复制为 .env 后填写
└── pyproject.toml
注意事项
-
默认管理员账号
admin/ 密码admin,上线前务必修改(写入db.py初始化逻辑或直接改库)。 -
会话签名密钥从环境变量
SECRET_KEY读取;未设置时每次启动随机生成,会导致重启后登录态失效。生产环境请复制.env.example为.env并填入:python -c "import secrets;print(secrets.token_hex(32))"
-
新增页面:在
pages/下新建模块并导出ar,然后在main.py中xxx.ar.to_app(app)注册。
许可
MIT License,详见 LICENSE。
Metadata
Release files for fasthtml-base 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fasthtml_base-0.1.2.tar.gz | 42.9 kB | Without provenance | Details for fasthtml_base-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fasthtml_base-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for fasthtml_base-0.1.2-py3-none-any.whl |
Total release size: 89.2 kB
Release files / fasthtml_base-0.1.2.tar.gz
| Download URL | fasthtml_base-0.1.2.tar.gz |
|---|---|
| Size | 42.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e92a54d87ec62ca288e3a38a9b8e808bb10067fca9f5cf6469dbf8ea488c5d0
|
|
BLAKE2b-256 checksum How to use checksums |
7902d952f2bf5788b8d5308d03c009bedc33f1b239b79d248fbadfaf11ccefb3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / fasthtml_base-0.1.2-py3-none-any.whl
| Download URL | fasthtml_base-0.1.2-py3-none-any.whl |
|---|---|
| Size | 46.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f506c9955da4aa9b7239e8d418b50e05abb472a1c0427e2b544ce51807da497
|
|
BLAKE2b-256 checksum How to use checksums |
0bfeab785557a6fd21ed9b3d669595bc75c1128a0fa49aa103a996250cad544c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for fasthtml-base 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.