Skip to main content

A command-line tool for quickly generating standard Dash application projects.

Project description

magic-dash logo

magic-dash

Python License PyPI Ruff

面向 Dash 应用开发的命令行脚手架,快速生成可运行、可扩展的 Python 数据应用模板。

magic-dash 内置单页面工具、多页面应用和带登录鉴权的管理系统模板,覆盖路由、菜单、配置、回调组织、状态页、数据库模型、用户与权限管理等常见工程起点。

快速开始

安装 magic-dash

pip install magic-dash -U

查看当前可生成的模板:

magic-dash list

交互式创建项目:

magic-dash create

指定模板创建项目:

magic-dash create --name magic-dash

指定生成目录:

magic-dash create --name magic-dash --path ./workspace

生成项目后,进入项目目录安装模板依赖并启动:

cd 生成的项目目录
pip install -r requirements.txt
python app.py

magic-dash-pro 模板需要先初始化数据库和登录密钥:

cd 生成的项目目录
pip install -r requirements.txt
python -m models.init_db
python app.py

默认访问地址:

http://127.0.0.1:8050

magic-dash-pro 初始化后的默认管理员账号:

用户名:admin
密码:admin123

完整命令说明见 magic-dash 命令使用

内置模板

模板 定位 典型场景 详细文档
simple-tool 单页面工具应用模板 内部小工具、数据处理表单、快速验证页面 查看
magic-dash 基础多页面应用模板 多页面后台雏形、数据看板、路由演示项目 查看
magic-dash-pro 多页面加登录鉴权管理系统模板 用户体系、角色权限、数据库管理后台 查看

magic-dash-pro 会在生成时选择后端类型:

文档导航

生成项目结构概览

simple-tool 生成最小单文件结构:

simple-tool/
├─ app.py
└─ requirements.txt

magic-dash 生成标准多页面结构:

magic-dash/
├─ assets/
├─ callbacks/
├─ components/
├─ configs/
├─ utils/
├─ views/
├─ server.py
├─ app.py
└─ requirements.txt

magic-dash-pro 在多页面结构基础上增加鉴权和数据模型:

magic-dash-pro/
├─ assets/
├─ callbacks/
├─ components/
├─ configs/
├─ models/
├─ utils/
├─ views/
├─ server.py
├─ app.py
└─ requirements.txt

目录职责、页面扩展和回调组织方式见 二次开发介绍

配置能力

生成后的 magic-dash 系列模板通过 configs/ 目录集中维护配置:

  • BaseConfig:应用标题、版本号、浏览器版本限制、更新日志弹窗、登录安全相关配置。
  • LayoutConfig:侧边栏宽度、核心页面呈现类型、页面搜索、登录页左侧内容类型。
  • RouterConfig:首页别名、侧边菜单、有效页面、独立页面、通配页面、公开页面。
  • AuthConfigmagic-dash-pro 的角色定义与页面访问规则。
  • DatabaseConfigmagic-dash-proSQLitePostgreSQLMySQL 数据库连接配置。

完整参数表见 配置参数说明

技术栈

magic-dash 命令行工具本身使用:

生成后的应用模板使用:

本地开发与测试

克隆仓库后,可以用可编辑模式安装:

pip install -e .

运行测试:

pytest

当前测试重点覆盖 magic-dash 命令行入口、模板列表、模板生成、magic-dash-pro 后端选择和非法模板错误处理。更多开发约定见 二次开发介绍

许可证

本项目基于 MIT License 开源。

更多教程

微信公众号「玩转 Dash」

玩转 Dash 公众号

「玩转 Dash」知识星球

玩转 Dash 知识星球

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

magic_dash-0.5.0rc3.tar.gz (13.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

magic_dash-0.5.0rc3-py3-none-any.whl (13.4 MB view details)

Uploaded Python 3

File details

Details for the file magic_dash-0.5.0rc3.tar.gz.

File metadata

  • Download URL: magic_dash-0.5.0rc3.tar.gz
  • Upload date:
  • Size: 13.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for magic_dash-0.5.0rc3.tar.gz
Algorithm Hash digest
SHA256 a75bd24f5548c333cee7be42937859bd6d66ed0b6dad60b27522fb9448b8c3fb
MD5 d3c6946ae5f48208cfb282cca6dd5097
BLAKE2b-256 63c749d814ca6325a1b30117101ea834a925b21063985ed596cccc909273b0cb

See more details on using hashes here.

File details

Details for the file magic_dash-0.5.0rc3-py3-none-any.whl.

File metadata

  • Download URL: magic_dash-0.5.0rc3-py3-none-any.whl
  • Upload date:
  • Size: 13.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for magic_dash-0.5.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 3df48c06974854de0f598089cf614b80180f5060f88c7b75a34b745932a62056
MD5 5a63c7b57072de40e1a7935991b039e8
BLAKE2b-256 0f043162980f206801cf963e8ac6d9e481bc417d423deb7ddad932c4f733e0ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page