2021-05-21

var express = require('express');
var mysql = require('mysql');
var urll = require('url');
var formidable = require('formidable');

var app = express();
app.use(express.static('node_modules'));
app.set('view engine','ejs');
app.set('views','./views');
//引入cookie模块
var cookie = require('cookie-parser');
app.use(cookie());
//配置数据库
var connection = mysql.createConnection({
    host:'localhost',
    user:'root',
    password:'123',
    database:'h5-56'
});
//连接数据库
connection.connect();

app.get('/index',function(req,res){
    connection.query('select * from cheshi',function(error,results,fields){
        res.render('index',{data:results});
        res.end();
    })
})

//添加操作
app.get('/add',function(req,res){
    res.render('add');
    res.end();
});
//执行添加操作
app.post('/doadd',function(req,res){
    var form = new formidable.IncomingForm();
    form.parse(req,function(err,fieles,fields){
        // console.log(fieles);
        // res.end();
        if(!err){
            var name = fieles.name;
            var age = fieles.age;
            var classid = fieles.classid;
            /* console.log(name+age+classid);
            res.end(); */
            var sql = 'insert into cheshi values(null,?,?,?)';
            var inserts = [name,age,classid];
            var sql = mysql.format(sql,inserts);
            connection.query(sql,function(error,results,fields){
                // console.log(results);
                if(results.affectedRows>0){
                    res.redirect('/index');
                    res.end();
                }
            })
        }
    })
})

//删除操作
app.get('/del',function(req,res){
    var url = req.url;
    var id = urll.parse(url,true).query.id;
    // console.log(id);
    connection.query('delete from cheshi where id='+id,function(error,results,fields){
        //console.log(results);
        if(results.affectedRows>0){
            res.redirect('/index');
            res.end();
        }
    })
})
//ajax删除
app.get('/delete',function(req,res){
    var url = req.url;
    var id = urll.parse(url,true).query.id;
    // console.log(id);
    var sql = 'delete from cheshi where id=?';
    var sql = mysql.format(sql,id);
    connection.query(sql,function(error,results,fields){
        //console.log(results);
        if(results.affectedRows>0){
            res.json({'y':1});
            res.end();
        }else{
            res.json({'y':0});
            res.end();
        }
    })
})

app.get('/edit',function(req,res){
    var url = req.url;
    var id = urll.parse(url,true).query.id;
    // console.log(id);
    connection.query('select * from cheshi where id='+id,function(error,results,fields){
        // console.log(results);
        res.render('edit',{data1:results});
        res.end();
    })
})

app.post('/doedit',function(req,res){
    var form = formidable.IncomingForm();
    form.parse(req,function(err,fieles,fields){
        // console.log(fieles);
        var id = fieles.id;
        var name = fieles.name;
        var age = fieles.age;
        var classid = fieles.classid;
        /* console.log(id+name+age+classid);
        res.end(); */
        var sql = "update cheshi set name=?,age=?,classid=? where id=?";
        var upates = [name,age,classid,id];
        // console.log(upates);
        var sql = mysql.format(sql,upates);
        connection.query(sql,function(error,results,fields){
            //  console.log(results);
           /* res.end(); */
            if(results.affectedRows>0){
                res.redirect('/index');
                res.end();
            }
        })
    })
})

app.get('/login',function(req,res){
    res.render('login');
    res.end();
})
app.post('/dologin',function(req,res){
    var form = new formidable.IncomingForm();
    form.parse(req,function(err,fieles,fields){
        // console.log(fieles);
        var user = fieles.user;
        var pass = fieles.pass;

        var sql = "select * from stu where user='"+user+"'";
        connection.query(sql,function(error,results,fields){
            // console.log(results);
            if(results.length>0){
                if(pass == results[0].pass){
                    res.write(`
                        <h1>successful</h1>
                        <script>
                            setTimeout(function(){
                                location.href = '/index';
                            },3000);
                        </script>
                    `)
                }else{
                    console.log('账号或者密码错误2阶段');
                    res.end();
                }
            }else{
                console.log('账户或密码错误1阶段');
                res.end();
            }
        })
    })
})
app.listen(8090);
```------------
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/bootstrap/dist/css/bootstrap.min.css">
    <script src="/jquery/dist/jquery.js"></script>
</head>

<body>
    <a href="#" class="btn btn-info">用户管理</a>
    <a href="/login" class="btn btn-info">用户登录</a>
    <a href="/add" class="btn btn-info">用户添加</a>
    <table class="table table-striped">
        <tr>
            <th>编号</th>
            <th>姓名</th>
            <th>年龄</th>
            <th>班级</th>
            <th>操作</th>
        </tr>
        <% for(var i=0;i<data.length;i++){ %>
        <tr>
            <td><%=data[i].id%></td>
            <td><%=data[i].name%></td>
            <td><%=data[i].age%></td>
            <td><%=data[i].classid%></td>
            <td>
                <a href="/edit?id=<%=data[i].id%>" class="btn btn-info">编辑</a>
                <a href="/del?id=<%=data[i].id%>" class="btn btn-info">删除</a>
                <a href="javascript:void(0);" class="btn btn-info a">ajax删除</a>
            </td>
        </tr>
        <%}%>
    </table>
    <script>
        // alert($);
        $('.a').click(function(){
            var id = $(this).parents('tr').find('td:first').html();
            //  console.log(id);
            var qd = confirm('是否要进行删除操作');
            var tr = $(this).parents('tr');
            if(qd){
                // console.log(111);
                $.get('/delete',{id:id},function(data){
                    if(data.y == 1){
                        alert('删除成功');
                        tr.remove();
                    }else{
                        alert('删除失败');
                    }
                })
            }
        })
    </script>
</body>
</html>
2021-03-26 20:54:33,596 - Model - INFO - Epoch 1 (1/200): 2021-03-26 20:57:40,380 - Model - INFO - Train Instance Accuracy: 0.571037 2021-03-26 20:58:16,623 - Model - INFO - Test Instance Accuracy: 0.718528, Class Accuracy: 0.627357 2021-03-26 20:58:16,623 - Model - INFO - Best Instance Accuracy: 0.718528, Class Accuracy: 0.627357 2021-03-26 20:58:16,623 - Model - INFO - Save model... 2021-03-26 20:58:16,623 - Model - INFO - Saving at log/classification/pointnet2_msg_normals/checkpoints/best_model.pth 2021-03-26 20:58:16,698 - Model - INFO - Epoch 2 (2/200): 2021-03-26 21:01:26,685 - Model - INFO - Train Instance Accuracy: 0.727947 2021-03-26 21:02:03,642 - Model - INFO - Test Instance Accuracy: 0.790858, Class Accuracy: 0.702316 2021-03-26 21:02:03,642 - Model - INFO - Best Instance Accuracy: 0.790858, Class Accuracy: 0.702316 2021-03-26 21:02:03,642 - Model - INFO - Save model... 2021-03-26 21:02:03,643 - Model - INFO - Saving at log/classification/pointnet2_msg_normals/checkpoints/best_model.pth 2021-03-26 21:02:03,746 - Model - INFO - Epoch 3 (3/200): 2021-03-26 21:05:15,349 - Model - INFO - Train Instance Accuracy: 0.781606 2021-03-26 21:05:51,538 - Model - INFO - Test Instance Accuracy: 0.803641, Class Accuracy: 0.738575 2021-03-26 21:05:51,538 - Model - INFO - Best Instance Accuracy: 0.803641, Class Accuracy: 0.738575 2021-03-26 21:05:51,539 - Model - INFO - Save model... 2021-03-26 21:05:51,539 - Model - INFO - Saving at log/classification/pointnet2_msg_normals/checkpoints/best_model.pth 我有类似于这样的一段txt文件,请你帮我写一段代码来可视化这些训练结果
02-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值