コード例 #1
0
def add_sensor():
    did = request.args.get('did')
    form = SensorForm()
    if form.validate_on_submit():
        sensor = Sensor()
        sensor.name = form.name.data
        sensor.describe = form.describe.data
        sensor.unit = form.unit.data
        sensor.device_id = did
        db.session.add(sensor)
        db.session.commit()
        return redirect(url_for('main.device', did=did))
    return render_template('main/add_sensor.html', form=form)
コード例 #2
0
def add_cgq():
    id = request.args.get('id')
    sen = Device.query.filter_by(id=id).first()
    form = ChuanGanQiFrom()
    if form.validate_on_submit():
        sensor = Sensor()
        sensor.name = form.sensors_name.data
        sensor.describe = form.sensors_description.data
        sensor.unit = form.sensors_unit.data
        sensor.devices_id = sen.id
        db.session.add(sensor)
        db.session.commit()
        return redirect(url_for('auth.shebei'))
    return render_template('equipment/add-chuanganqi.html', form=form)