# host_management **Repository Path**: zuihaodewomen_admin/host_management ## Basic Information - **Project Name**: host_management - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-03 - **Last Updated**: 2026-04-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 结构目录说明 ``` host_management/ ├── host_management/ # 项目配置 │ ├── settings.py # 全局配置 │ ├── celery.py # Celery 配置 │ ├── middleware.py # 请求耗时中间件 │ └── urls.py # 主路由 ├── api/ # 业务应用 │ ├── models.py # 数据模型(主机/城市/机房/统计) │ ├── serializers.py # 序列化器 │ ├── views.py # 接口视图 │ ├── tasks.py # 异步/定时任务 │ └── urls.py # 接口路由 └── manage.py ``` # 启动顺序 ``` # 安装项目依赖(使用清华镜像加速) pip install -i https://pypi.tuna.tsinghua.edu.cn/simple django djangorestframework mysqlclient celery django-celery-beat ping3 python-dotenv redis==4.5.4 # 启动redis redis-server # mysql准备 # 登录 MySQL mysql -u root -p # 创建项目数据库 CREATE DATABASE host_manage CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 1. 数据库配置(settings.py) DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'host_manage', 'USER': 'root', 'PASSWORD': '你的MySQL密码', 'HOST': '127.0.0.1', 'PORT': '3306', } } # 生成迁移文件 python manage.py makemigrations api # 执行迁移,创建所有表 python manage.py migrate # 启动 Django Web 服务 python manage.py runserver # 创建超级管理员 python manage.py createsuperuser # 启动 Celery 任务消费者 celery -A host_management worker -l info # 启动 Celery 定时任务调度器 celery -A host_management beat -l info # 接口文档(Postman 导入即用) https://fileres.m.tbkt.cn/cms_data/2026/04/03/2026040309475275011.json ``` | 接口地址 | 功能 | 请求方式 | | ---- | ---- |-------| /api/cities/| 城市增删改查| GET/POST/PUT/DELETE | /api/idcs/| 机房增删改查| GET/POST/PUT/DELETE | /api/hosts/| 主机增删改查| GET/POST/PUT/DELETE | /api/hosts/{id}/ping/| 探测主机是否可达| GET |