Plotly-DashGo 开源项目使用教程

Plotly-DashGo 开源项目使用教程

Plotly-DashGo 开源后台管理系统DashGo,一个开箱即用的完全基于Python技术栈的全栈快速开发框架。 A out-of-the-box web framework for Plotly Dash development that is builded by pure Python. Plotly-DashGo 项目地址: https://gitcode.com/gh_mirrors/pl/Plotly-DashGo

1. 项目介绍

Plotly-DashGo 是一个基于 Python 技术栈的开箱即用的全栈快速开发框架。它基于 Plotly Dash 框架和 Fac 开源组件库进行开发,允许开发者使用 Python 语言实现全栈的后台管理系统。Plotly-DashGo 拥有多页面管理、细粒度权限管理、自带用户和角色权限管理、国际化组件、密码和 OTP 登录、OAuth2 接口支持等特性,非常适合需要快速构建企业级后台管理系统的开发者。

2. 项目快速启动

环境准备

确保您的系统中已安装 Python。根据您的操作系统,选择相应的依赖文件进行安装:

  • Windows 用户:运行 python -m pip install -r requirements_win.txt
  • Linux 用户:运行 python -m pip install -r requirements_linux.txt

推荐使用虚拟环境进行开发,具体设置请参考虚拟环境设置教程

初始化数据库和启动应用

切换到项目的 src 目录下:

  • Windows: cd /d e:\xxxx
  • Linux: cd /app/xxxx

初始化数据库表结构和 admin 管理员数据:

  • 运行 python -c "from database.sql_db.conn import create_rds_table; create_rds_table()" 初始化表结构
  • 运行 python -c "from database.sql_db.conn import init_rds_data; init_rds_data()" 初始化 admin 用户

启动应用:

  • Windows: 运行 waitress-serve --host=0.0.0.0 --port=8090 --url-scheme=http --trusted-proxy=* --trusted-proxy-headers=x-forwarded-for --threads=8 app:server
  • Linux: 运行 gunicorn --capture-output -w 4 -b 0.0.0.0:8090 app:server

默认账号为 admin,密码为 admin123。启动后,根据日志提示中的 URL 进行访问。

如果需要使用任务中心模块,运行 python app_apscheduler.py 启动任务进程。

请注意,默认启动使用的是 sqlite 数据库。如需用于生产环境,请根据 config/dashgo.ini 调整相关 MySQL 数据库配置。

3. 应用案例和最佳实践

以下是一个简单的应用案例,展示如何在 Plotly-DashGo 中添加新应用:

# 导入所需的模块
from common.utilities.util_menu_access import MenuAccess
import feffery_antd_components as fac
import feffery_utils_components as fuc
from common.utilities.util_logger import Log
from dash_components import Card

# 设置应用的标题、图标和显示顺序
title = '应用1'
icon = None
order = 2
logger = Log.get_logger(__name__)

# 注册权限
access_metas = (
    '应用1-基础权限',
    '应用1-权限1',
    '应用1-权限2',
)

# 定义视图页面的渲染方法
def render_content(menu_access: MenuAccess, **kwargs):
    return fac.AntdFlex([
        [
            Card(
                fac.AntdStatistic(
                    title='展示',
                    value=fuc.FefferyCountUp(end=100, duration=3),
                ),
                title='应用1-权限1',
            )
        ] if menu_access.has_access('应用1-权限1') else [],
        [
            Card(
                fac.AntdStatistic(
                    title='展示',
                    value=fuc.FefferyCountUp(end=200, duration=3),
                ),
                title='应用1-权限2',
            )
        ] if menu_access.has_access('应用1-权限2') else [],
    ], wrap='wrap')

在 Plotly-DashGo 中,最佳实践是按照项目的结构组织代码,确保代码的模块化和可维护性。

4. 典型生态项目

目前,Plotly-DashGo 的生态项目包括但不限于:

  • dashgo-knowledge:一个自主开发的子系统,通过 OAuth2 接口和 Iframe 实现接入。

开发者可以根据自己的需求,创建和集成更多生态项目,以丰富 Plotly-DashGo 的功能和应用场景。

Plotly-DashGo 开源后台管理系统DashGo,一个开箱即用的完全基于Python技术栈的全栈快速开发框架。 A out-of-the-box web framework for Plotly Dash development that is builded by pure Python. Plotly-DashGo 项目地址: https://gitcode.com/gh_mirrors/pl/Plotly-DashGo

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

施余牧

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值