Exemplo n.º 1
0
def add_lab():
    if request.method == "GET":
        return render_template("admin/add_lab.html")
    else:
        key ,values = map(request.form.get,("key","values"))
        Laboratory.insert(g.db,key=key,json_data={"data":values})
        return render_template("laboratory.html")
Exemplo n.º 2
0
 def add_new_lab(self, info):
     try:
         lab = Laboratory()
         lab.name = info.get('name')
         lab.notice = info.get('notice')
         lab.devices = json.dumps(self.format_devices(info.get('devices')))
         db.session.add(lab)
         db.session.commit()
     except Exception as e:
         db.session.rollback()
         raise Exception("请使用英文富符号")
Exemplo n.º 3
0
def add_lab():
    if request.method == "GET":
        return render_template("admin/add_lab.html")
    else:
        key, values = map(request.form.get, ("key", "values"))
        stmt = Laboratory.get_data(g.db, key)
        if stmt:
            return jsonify(data=stmt.content)

        Laboratory.insert(g.db, key=key, json_data={"data": values})
        return render_template("laboratory.html")
Exemplo n.º 4
0
def api_lib_index():
    stmt =  Laboratory.show_last(g.db)
    if stmt:
        stmt = stmt[0]
        return jsonify(data=stmt)
    else:
        return jsonify({"data":""})
Exemplo n.º 5
0
def api_lib_data(json_key):
    stmt = Laboratory.get_data(g.db, json_key)
    if stmt:
        # stmt = stmt[0]
        return jsonify(data=stmt.content)
    else:
        return jsonify({"data": ""})
Exemplo n.º 6
0
def api_lib_index():
    stmt = Laboratory.show_last(g.db)
    if stmt:
        print(dir(stmt))
        key = stmt.key
        data = stmt.content
        return jsonify(data=data, key=key)
    else:
        return jsonify({"data": ""})
Exemplo n.º 7
0
def index_template():
    lab_data = Laboratory.show_all(g.db)
    print(lab_data)
    return render_template("laboratory.html", json_data=lab_data)