- edc-web: Flask 项目骨架(设备管理、测试操作、测试信息三大页面) - edc_server: 升级子模块(tb_serialnet 透传支持) - docs: 测试工装EDC管理系统需求文档
29 lines
704 B
Python
29 lines
704 B
Python
"""设备页面 API"""
|
|
|
|
from flask import Blueprint, jsonify, render_template, request
|
|
from app.models import get_all_devices, update_device_name
|
|
|
|
bp = Blueprint("devices", __name__)
|
|
|
|
|
|
@bp.route("/")
|
|
def index():
|
|
"""设备列表页(默认首页)"""
|
|
return render_template("devices.html")
|
|
|
|
|
|
@bp.route("/api/devices")
|
|
def api_devices():
|
|
"""获取所有设备列表"""
|
|
devices = get_all_devices()
|
|
return jsonify(devices)
|
|
|
|
|
|
@bp.route("/api/devices/<int:device_id>/name", methods=["PUT"])
|
|
def api_update_name(device_id):
|
|
"""修改设备名称"""
|
|
data = request.get_json()
|
|
name = data.get("name", "")
|
|
update_device_name(device_id, name)
|
|
return jsonify({"ok": True})
|