更新
This commit is contained in:
7
.env
7
.env
@@ -27,12 +27,13 @@ EMAIL_HOST=smtp.qq.com
|
|||||||
EMAIL_PORT=465
|
EMAIL_PORT=465
|
||||||
EMAIL_USE_SSL=True
|
EMAIL_USE_SSL=True
|
||||||
EMAIL_USE_TLS=False
|
EMAIL_USE_TLS=False
|
||||||
EMAIL_HOST_USER=<redacted>
|
EMAIL_HOST_USER=your_email@example.com
|
||||||
EMAIL_HOST_PASSWORD=<redacted>
|
EMAIL_HOST_PASSWORD=your_email_password_or_app_key
|
||||||
DEFAULT_FROM_EMAIL=<redacted>
|
DEFAULT_FROM_EMAIL=your_email@example.com
|
||||||
|
|
||||||
# 注册邮箱验证码开关(0=关闭,1=开启)
|
# 注册邮箱验证码开关(0=关闭,1=开启)
|
||||||
REGISTER_EMAIL_VERIFICATION=0
|
REGISTER_EMAIL_VERIFICATION=0
|
||||||
|
|
||||||
# Hertz Captcha Configuration
|
# Hertz Captcha Configuration
|
||||||
HERTZ_CAPTCHA_LENGTH=4
|
HERTZ_CAPTCHA_LENGTH=4
|
||||||
HERTZ_CAPTCHA_WIDTH=120
|
HERTZ_CAPTCHA_WIDTH=120
|
||||||
|
|||||||
BIN
data/db.sqlite3
BIN
data/db.sqlite3
Binary file not shown.
BIN
docs/img/ac87c1f6-a28b-4959-ae98-cab5e150c56b.png
Normal file
BIN
docs/img/ac87c1f6-a28b-4959-ae98-cab5e150c56b.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
BIN
docs/img/img_1.png
Normal file
BIN
docs/img/img_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 108 KiB |
BIN
docs/img/img_2.png
Normal file
BIN
docs/img/img_2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 113 KiB |
BIN
docs/img/img_3.png
Normal file
BIN
docs/img/img_3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
18
get_machine_code.py
Normal file
18
get_machine_code.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import platform
|
||||||
|
import uuid
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
|
||||||
|
def get_machine_id() -> str:
|
||||||
|
"""生成机器码。
|
||||||
|
|
||||||
|
根据当前系统信息(平台、架构、MAC地址)生成唯一机器码,
|
||||||
|
使用 SHA256 取前16位并转大写,前缀为 HERTZ_STUDIO_。
|
||||||
|
"""
|
||||||
|
system_info = f"{platform.platform()}-{platform.machine()}-{uuid.getnode()}"
|
||||||
|
return 'HERTZ_STUDIO_' + hashlib.sha256(system_info.encode()).hexdigest()[:16].upper()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
machine_code = get_machine_id()
|
||||||
|
print(f"您的机器码是: {machine_code}")
|
||||||
@@ -81,17 +81,14 @@ INSTALLED_APPS = [
|
|||||||
'channels',
|
'channels',
|
||||||
'drf_spectacular',
|
'drf_spectacular',
|
||||||
|
|
||||||
# Local apps
|
# 必备注册的app,不要删
|
||||||
'hertz_demo',
|
'hertz_demo', # 初始化演示模块
|
||||||
'hertz_studio_django_captcha',
|
'hertz_studio_django_captcha', # 验证码模块
|
||||||
'hertz_studio_django_auth', # 权限管理系统
|
'hertz_studio_django_auth', # 权限模块
|
||||||
'hertz_studio_django_notice', # 通知公告模块
|
|
||||||
'hertz_studio_django_ai',
|
|
||||||
'hertz_studio_django_system_monitor', # 系统监测模块
|
'hertz_studio_django_system_monitor', # 系统监测模块
|
||||||
'hertz_studio_django_log', # 日志管理模块
|
'hertz_studio_django_log', # 日志管理模块
|
||||||
'hertz_studio_django_wiki', # 知识管理模块
|
|
||||||
'hertz_studio_django_codegen', # 代码生成模块
|
# ======在下面导入你需要的app======
|
||||||
'hertz_studio_django_yolo', # YOLO目标检测模块
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -19,19 +19,19 @@ from django.conf import settings
|
|||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
|
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
|
||||||
from . import views
|
from . import views
|
||||||
from hertz_studio_django_captcha import urls as captcha_urls
|
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
|
||||||
_BASE_DIR = Path(__file__).resolve().parent.parent
|
|
||||||
sys.path.insert(0, str(_BASE_DIR))
|
|
||||||
from hertz_studio_django_codegen import urls as codegen_urls
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|
||||||
|
# API documentation routes
|
||||||
|
path('api/docs/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
|
||||||
|
path('api/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
|
||||||
|
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
|
||||||
|
|
||||||
# 首页路由
|
# 首页路由
|
||||||
path('', views.index, name='index'),
|
path('', views.index, name='index'),
|
||||||
|
|
||||||
# Hertz Captcha routes
|
# Hertz Captcha routes
|
||||||
path('api/captcha/', include(captcha_urls)),
|
path('api/captcha/', include('hertz_studio_django_captcha.urls')),
|
||||||
|
|
||||||
# Hertz Auth routes
|
# Hertz Auth routes
|
||||||
path('api/', include('hertz_studio_django_auth.urls')),
|
path('api/', include('hertz_studio_django_auth.urls')),
|
||||||
@@ -39,33 +39,15 @@ urlpatterns = [
|
|||||||
# Demo app routes
|
# Demo app routes
|
||||||
path('', include('hertz_demo.urls')),
|
path('', include('hertz_demo.urls')),
|
||||||
|
|
||||||
# Hertz AI routes
|
|
||||||
path('api/ai/', include('hertz_studio_django_ai.urls')),
|
|
||||||
|
|
||||||
# Hertz System Monitor routes
|
# Hertz System Monitor routes
|
||||||
path('api/system/', include('hertz_studio_django_system_monitor.urls')),
|
path('api/system/', include('hertz_studio_django_system_monitor.urls')),
|
||||||
|
|
||||||
# Hertz System Notification routes
|
|
||||||
path('api/notice/', include('hertz_studio_django_notice.urls')),
|
|
||||||
|
|
||||||
# Hertz Log routes
|
# Hertz Log routes
|
||||||
path('api/log/', include('hertz_studio_django_log.urls')),
|
path('api/log/', include('hertz_studio_django_log.urls')),
|
||||||
|
|
||||||
## Hertz Wiki routes
|
|
||||||
path('api/wiki/', include('hertz_studio_django_wiki.urls')),
|
|
||||||
|
|
||||||
# Hertz Codegen routes
|
# ===========在下面添加你需要的路由===========
|
||||||
path('api/codegen/', include((codegen_urls, 'codegen'), namespace='codegen')),
|
|
||||||
|
|
||||||
# Hertz YOLO routes
|
|
||||||
path('api/yolo/', include('hertz_studio_django_yolo.urls')),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# API documentation routes
|
|
||||||
path('api/docs/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
|
|
||||||
path('api/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
|
|
||||||
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# 在开发环境下提供媒体文件服务
|
# 在开发环境下提供媒体文件服务
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Django==5.2.6
|
Django==5.1.2
|
||||||
channels==4.0.0
|
channels==4.0.0
|
||||||
channels-redis==4.2.0
|
channels-redis==4.2.0
|
||||||
djangorestframework==3.14.0
|
djangorestframework==3.14.0
|
||||||
@@ -22,12 +22,16 @@ scikit-learn>=1.1.0
|
|||||||
joblib>=1.2.0
|
joblib>=1.2.0
|
||||||
aiohttp>=3.13.2
|
aiohttp>=3.13.2
|
||||||
|
|
||||||
hertz-studio-django-ai>=0.1.0
|
|
||||||
hertz-studio-django-auth>=0.1.0
|
|
||||||
hertz-studio-django-captcha>=0.1.0
|
# ================hertz所有官方库================
|
||||||
hertz-studio-django-log>=0.1.0
|
hertz-studio-django-ai
|
||||||
hertz-studio-django-notice>=0.1.0
|
hertz-studio-django-auth
|
||||||
hertz-studio-django-system-monitor>=0.1.0
|
hertz-studio-django-captcha
|
||||||
hertz-studio-django-wiki>=0.1.0
|
hertz-studio-django-log
|
||||||
hertz-studio-django-yolo>=0.1.0
|
hertz-studio-django-notice
|
||||||
hertz-studio-django-codegen>=0.1.0
|
hertz-studio-django-system-monitor
|
||||||
|
hertz-studio-django-wiki
|
||||||
|
hertz-studio-django-yolo
|
||||||
|
hertz-studio-django-codegen
|
||||||
|
hertz-studio-django-yolo-train
|
||||||
133
后端部署教程.md
Normal file
133
后端部署教程.md
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
# 后端部署教程
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 一、**环境要求**
|
||||||
|
|
||||||
|
- `Python 3.10+`(建议 3.12.3)
|
||||||
|
- 操作系统:Windows
|
||||||
|
- 可选:本地 `Redis` 服务(默认地址 `redis://127.0.0.1:6379`)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 二、 获取机器码并激活
|
||||||
|
|
||||||
|
### 1)获取机器码:
|
||||||
|
|
||||||
|
```python
|
||||||
|
python get_machine_code.py
|
||||||
|
```
|
||||||
|
|
||||||
|
允许后会获得一个机器码,例如:HERTZ_STUDIO_XXXXXXXXXXXXXXXX
|
||||||
|
|
||||||
|
### 2)将获取到的机器码在激活码管理系统上添加
|
||||||
|
|
||||||
|
进行系统地址(没有账号请找管理员申请):http://activate.hzsystems.cn/admin/machinecode/
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 三、下载需要的app库
|
||||||
|
|
||||||
|
### 1)单独获取库,例如需要yolo模块库:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install hertz-studio-django-yolo -i https://hertz:hertz@hzpypi.hzsystems.cn/simple/
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2)下载全部库
|
||||||
|
|
||||||
|
pip install -r requirements.txt -i https://hzpypi.hzsystems.cn/simple/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
注:所有库都在requirements.txt的最下面
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 四、配置django
|
||||||
|
|
||||||
|
### 1)将下载的app注册到django项目中
|
||||||
|
|
||||||
|
在根目录下面的hertz_server_django文件夹下面的setting文件(如下图)中注册app
|
||||||
|
|
||||||
|
如下图我用到了notice、ai、wiki等模块
|
||||||
|

|
||||||
|
|
||||||
|
### 2)注册app后配置路由
|
||||||
|
|
||||||
|
在根目录下面的hertz_server_django文件夹下面的urls.py文件(如下图)中配置路由
|
||||||
|
|
||||||
|
配置路由参考,例如我要配置名为xxx的路由:
|
||||||
|
|
||||||
|
```python
|
||||||
|
path('api/xxx/', include('hertz_studio_django_xxx.urls')),
|
||||||
|
```
|
||||||
|
|
||||||
|
如下图我配置了notice、ai、wiki等路由
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## **五、启动服务**
|
||||||
|
|
||||||
|
- 通过脚本启动(支持端口参数):
|
||||||
|
- `python start_server.py --port 8000`
|
||||||
|
- 访问地址:
|
||||||
|
- `http://127.0.0.1:8000/`
|
||||||
|
- WebSocket:`ws://127.0.0.1:8000/ws/`
|
||||||
|
- 首次启动将自动执行:
|
||||||
|
- 扫描并注册新应用到 `INSTALLED_APPS` 与 `urls.py`(`start_server.py:173`、`start_server.py:98`)。
|
||||||
|
- 执行 `makemigrations` 与 `migrate`(`start_server.py:1109`)。
|
||||||
|
- 初始化超级管理员/部门/菜单/角色等(`start_server.py:877`)。
|
||||||
|
- 创建菜单生成器工具 `generate_menu.py`(`start_server.py:780`)。
|
||||||
|
- 启动 `daphne` 并开启热重启监听(`start_server.py:1016`、`start_server.py:1063`)。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 六、默认账号
|
||||||
|
|
||||||
|
- 超级管理员:
|
||||||
|
- 用户名:`hertz`
|
||||||
|
- 密码:`hertz`
|
||||||
|
- 普通用户
|
||||||
|
- 用户名:`demo`
|
||||||
|
- 密码:`123456`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## **七、问题排查**
|
||||||
|
|
||||||
|
### 1)`daphne` 或 `watchdog` 未安装:
|
||||||
|
|
||||||
|
运行:`pip install daphne watchdog -i https://pypi.tuna.tsinghua.edu.cn/simple`(`start_server.py:1235-1248` 有依赖检查)。
|
||||||
|
|
||||||
|
### 2)Redis 未运行:
|
||||||
|
|
||||||
|
安装并启动 Redis,或调整 `REDIS_URL` 指向可用实例。
|
||||||
|
|
||||||
|
### 3)视频检测结果展示不了
|
||||||
|
|
||||||
|
需配置ffmpeg环境,参考文章:https://blog.csdn.net/csdn_yudong/article/details/129182648
|
||||||
|
|
||||||
|
ffmpeg压缩包在根目录下面的static目录下,如下图。
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## **八、项目结构**
|
||||||
|
|
||||||
|
- 核心配置:`hertz_server_django/settings.py`、`hertz_server_django/urls.py`
|
||||||
|
- 启动脚本:`start_server.py`
|
||||||
|
- 依赖清单:`requirements.txt`
|
||||||
|
- 静态资源:`static/`,媒体资源:`media/`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 九、**快速启动**
|
||||||
|
|
||||||
|
- 安装依赖:`pip install -r requirements.txt -i https://hertz:hertz@hzpypi.hzsystems.cn/simple/`
|
||||||
|
- 启动服务:`python start_server.py --port 8000`
|
||||||
Reference in New Issue
Block a user