コード例 #1
0
ファイル: views.py プロジェクト: xiajieok/Earth
 def post(self):
     json_data = request.get_json(force=True)
     print('提交到的数据', json_data)
     try:
         blog_id = models.blog.query.order_by(
             models.blog.id.desc()).first().id
         new_id = int(blog_id) + 1
     except:
         new_id = 1
     res = models.blog(id=new_id,
                       hostname=json_data['hostname'],
                       sn=json_data['sn'],
                       type=json_data['type'],
                       os=json_data['os'],
                       vendor=json_data['vendor'],
                       model=json_data['model'],
                       cpu_processor=json_data['cpu_processor'],
                       cpu_model=json_data['cpu_model'],
                       cpu_num=json_data['cpu_num'],
                       cpu_physical=json_data['cpu_physical'],
                       memory=json_data['memory'],
                       disk=json_data['disk'],
                       idc=json_data['idc'],
                       create_date=datetime.now(),
                       update_date=datetime.now(),
                       status=json_data['status'])
     db.session.add(res)
     db.session.commit()
     db.session.close()
     return json_data, 200
コード例 #2
0
    def post(self):
        json_data = request.get_json(force=True)
        print('提交到的数据', json_data)

        res = models.Asset(hostname=json_data['hostname'],
                           ip=json_data['ip'],
                           sn=json_data['sn'],
                           type=json_data['type'],
                           os=json_data['os'],
                           vendor=json_data['vendor'],
                           model=json_data['model'],
                           cpu_processor=json_data['cpu_processor'],
                           cpu_model=json_data['cpu_model'],
                           cpu_num=json_data['cpu_num'],
                           cpu_physical=json_data['cpu_physical'],
                           memory=json_data['memory'],
                           disk=json_data['disk'],
                           idc=json_data['idc'],
                           create_date=datetime.now(),
                           update_date=datetime.now(),
                           status=json_data['status'])
        db.session.add(res)
        db.session.commit()
        db.session.close()
        return json_data, 200
コード例 #3
0
def exportAllHomeWork():
    basedir = current_app.config['BASE_DIR']
    save_filename1 = '全部作业导出-' + datetime.now().strftime('%m-%d_%H_%M_%S') + '.zip'
    save_filename = os.path.join(basedir, 'Download', save_filename1)
    if not os.path.exists(os.path.join(basedir, 'Download')):
        os.makedirs(os.path.join(basedir, 'Download'))  # 文件夹不存在就创建
    make_zip(os.path.join(basedir, 'ZY'), save_filename)
    return send_file(save_filename, as_attachment=True, attachment_filename=save_filename1)
コード例 #4
0
 def put(self, asset_id):
     json_data = request.get_json(force=True)
     print('更新操作')
     for i in json_data:
         models.Asset.query.filter_by(id=asset_id).update({
             i:
             json_data[i],
             "update_date":
             datetime.now()
         })
     db.session.commit()
     db.session.close()
     return 200