前端学习(1361):学生档案信息管理3

service.js

//引入http模块
const http = require('http');
//创建网站服务器
const app = http.createServer();
//引入路由
const getRouter = require('router');const router = getRouter();const template = require('art-template');const path = require('path');const serveStatic = require('serve-static');//静态资源服务
const serve = serveStatic(path.join(__dirname));
//配置模板根目录
template.defaults.root = path.join(__dirname);
router.get('/add', (req, res) => {/* res.end('test') */let html = template('index.art', {});res.end(html);
})
router.get('/list', (req, res) => {let html = template('list.art', {});res.end(html);
})
require('./connect.js')
const Student = require('./user.js')
app.on('request', (req, res) => {router(req, res, () => {})serve(req, res, () => {})
});
app.listen(3000);
console.log('服务器启动成功');

user.js

const mongoose = require('mongoose');const studentsSchema = new mongoose.Schema({name: {type: String,required: true,minlength: 2,maxlength: 10},age: {type: Number,min: 10,max: 25},sex: {type: String},email: String,hobbies: [String],collage: String,enterDate: {type: Date,default: Date.now}});
const Student = mongoose.model('Student', studentsSchema);module.exports = Student;

connect.js

//链接数据库
const mongoose = require('mongoose');
//链接数据库
mongoose.connect('mongodb://localhost/playground', { useNewUrlParser: true }).then(() => console.log('数据库安装成功')).catch(() => console.log('数据库链接失败'))

index.artlis

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"><title>学生档案</title><link rel="stylesheet" href="./main.css">
</head>
<body><form action="/add" method="post"><fieldset><legend>学生档案</legend><label>姓名: <input class="normal" type="text" autofocus placeholder="请输入姓名" name="name"></label><label>年龄: <input class="normal"  type="text" placeholder="请输入年龄" name="age"></label><label>性别: <input type="radio" value="0" name="sex"> 男<input type="radio" value="1" name="sex"> 女</label><label>邮箱地址: <input class="normal" type="text" placeholder="请输入邮箱地址" name="email"></label><label>爱好: <input type="checkbox" value="敲代码" name="hobbies"> 敲代码<input type="checkbox" value="打篮球" name="hobbies"> 打篮球<input type="checkbox" value="睡觉" name="hobbies"> 睡觉</label><label>所属学院: <select class="normal" name="collage"><option value="前端与移动开发">前端与移动开发</option><option value="PHP">PHP</option><option value="JAVA">JAVA</option><option value="Android">Android</option><option value="IOS">IOS</option><option value="UI设计">UI设计</option><option value="C++">C++</option></select></label><label>入学日期: <input type="date" class="normal" name="enterDate"></label><label class="btn"><input type="submit" value="提交" class="normal"></label></fieldset></form>
</body>
</html>

 

list.art

 

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>学员信息</title><link rel="stylesheet" href="./list.css">
</head>
<body><table><caption>学员信息</caption><tr><th>姓名</th><th>年龄</th><th>性别</th><th>邮箱地址</th><th>爱好</th><th>所属学院</th><th>入学时间</th></tr>{{each students}}<tr><th>{{$value.name}}</th><th>{{$value.age}}</th><th>{{$value.sex == '0' ? '男' : '女'}}</th><th>{{$value.email}}</th><th>{{each $value.hobbies}}<span>{{$value}}</span>{{/each}}</th><th>{{$value.collage}}</th><th>{{dateformat($value.enterDate, 'yyyy-mm-dd')}}</th></tr>{{/each}}</table>
</body>
</html>

main.css


body {margin: 0;padding: 0 0 40px;background-color: #F7F7F7;font-family: '微软雅黑';
}form {max-width: 640px;width: 100%;margin: 24px auto;font-size: 28px;
}label {display: block;margin: 10px 10px 15px;font-size: 24px;
}.normal {display: block;width: 100%;height: 40px;font-size: 22px;margin-top: 10px;padding: 6px 10px;color: #333;border: 1px solid #CCC;box-sizing: border-box;
}.btn {margin-top: 30px;
}.btn input {color: #FFF;background-color: green;border: 0 none;outline: none;cursor: pointer;
}input[type="file"] {/*opacity: 0;*/width: 120px;position: absolute;right: 0;z-index: 9;
}.import {height: 40px;position: relative;
}

list.css


body {margin: 0;padding: 0 0 40px;background-color: #F7F7F7;font-family: '微软雅黑';
}form {max-width: 640px;width: 100%;margin: 24px auto;font-size: 28px;
}label {display: block;margin: 10px 10px 15px;font-size: 24px;
}.normal {display: block;width: 100%;height: 40px;font-size: 22px;margin-top: 10px;padding: 6px 10px;color: #333;border: 1px solid #CCC;box-sizing: border-box;
}.btn {margin-top: 30px;
}.btn input {color: #FFF;background-color: green;border: 0 none;outline: none;cursor: pointer;
}input[type="file"] {/*opacity: 0;*/width: 120px;position: absolute;right: 0;z-index: 9;
}.import {height: 40px;position: relative;
}

运行结果

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/420209.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

mysql查询结果每条记录两个字段求和_MYSQL实现将两个结果集合并,并且按照时间字段分组,其他字段的值求和...

本查询是计算两个表的相同时间(天)的记录数1.合并就用UNION ALL第一个查询:SELECTDATE_FORMAT(BIND_TIME,%Y-%m-%d) time,count(*)FROM bind_histGROUP BY time第二个查询:SELECTDATE_FORMAT(BIND_TIME,%Y-%m-%d) time,count(*)FROM bind_failedGROUP BY time合并后为:SELECTDA…

前端学习(1362):学生档案信息管理4

service.js //引入http模块 const http require(http); //创建网站服务器 const app http.createServer(); //引入路由 const getRouter require(router); const router getRouter(); const template require(art-template); const path require(path); const serveStat…

SharePoint 2013 图文开发系列之WebPart

SharePoint 2013 图文开发系列之WebPart 原文:SharePoint 2013 图文开发系列之WebPart这是我们介绍SharePoint开发入门的第一篇&#xff0c;在这一篇里&#xff0c;我们会介绍SharePoint开发的几个关键物理路径&#xff0c;一些开发技巧和最基础的WebPart开发。 开发工具 在Sha…

前端学习(1363):学生档案信息管理5

service.js //引入http模块 const http require(http); //创建网站服务器 const app http.createServer(); //引入路由 const getRouter require(router); const router getRouter(); const template require(art-template); const path require(path); const serveStat…

mysql c webservice_如何编写webservice c

展开全部采用的工具VS2010生成e69da5e6ba9062616964757a686964616f31333363396337工程1. 生成webservice工程&#xff1a;建 ASP.NET 空WEB 应用程序。2. 在建好的ASP.NET 空WEB应用程序中新建项“web 服务”。完成上述内容工程结构如下图下面主要的操作就是在webservice1.asmx…

Web 前沿——HTML5 Form Data 对象的使用(转)

XMLHttpRequest Level 2 添加了一个新的接口——FormData。利用 FormData 对象&#xff0c;我们可以通过 JavaScript 用一些键值对来模拟一系列表单控件&#xff0c;我们还可以使用 XMLHttpRequest 的 send() 方法来异步的提交表单。与普通的 Ajax 相比&#xff0c;使用 FormDa…

mysql 字符串类型 小数_在Mysql中,小数数据类型是指由字符串来表示的数字。(  )...

【单选题】中药检查项下的总灰分是指( )【单选题】中国药典规定取某样品 2.00g ,系指称取的质量应为( )【多选题】中国药典2015版鉴别中药真伪的方法有( )【多选题】中药及其制剂的鉴别方法包括( )【多选题】检查中药水分可以采用的方法有( )【单选题】药品检验工作的基本顺序为…

(五十五)iOS多线程之GCD

GCD的全称为Grand Central Dispatch&#xff0c;翻译为大中央调度&#xff0c;是Apple开发的一个多线程编程解决方法。 进程和线程的概念&#xff1a; 正在进行中的程序被称为进程&#xff0c;负责程序运行的内存分配&#xff0c;每一个进程都有自己独立的虚拟内存空间。 线程是…

mysql优化varchar索引_MySQL优化--概述以及索引优化分析

一、MySQL概述1.1、MySQL文件含义通过如下命令查看show variables like %dir%;MySQL文件位置及含义名称值备注basedir/usr/安装路径character_sets_dir/usr/share/mysql-8.0/charsets/保存字符集目录datadir/var/lib/mysql/数据存放路径lc_messages_dir/usr/share/mysql-8.0/pl…

atitit.orm的缺点与orm框架市场占有率,选型attilax总结

atitit.orm的缺点与orm框架市场占有率&#xff0c;选型attilax总结 1. attilax的orm框架要求 1 2. orm框架市场占有率 2 3. spring jdbc templt 3 4. eclipselink /toplink 不好用 4 5. jooq 的总结 4 6. attilax的选择 atiorm 4 7. 参考 4 1. attilax的orm框架要求 1.无需配置…

前端学习(1366):express入门

const express require(express);const app express(); app.get(/, (req, res) > {//send 响应内容的累心//http 状态码res.send(hello geyao); }) app.get(/list, (req, res) > {//send 响应内容的累心//http 状态码res.send({ name: 张三, age: 20 }); }) app.listen…

python中参数传递_python中参数传递

在编程语言中&#xff0c;函数的参数传递有两种情况&#xff1a;按值类型传递num 10def double(arg):argarg*2print(arg)double(num)调用该函数&#xff0c;传入一个变量&#xff0c;其实传入的是该变量的一个副本&#xff0c;该变量在函数中发生变化&#xff0c;不影响函数外…

Hybrid框架UI重构之路:五、前端那点事儿(HTML、CSS)

上文回顾 &#xff1a;Hybird框架UI重构之路&#xff1a;四、分而治之 这里讲述在开发的过程中&#xff0c;一些HTML、CSS的关键点。 单页模式的页面结构在单页模式中&#xff0c;弱化HTML的概念&#xff0c;把HTML当成一个容器&#xff0c;BODY中显示的主体内容才是页面&#…

前端学习(1367):什么是中间件

const express require(express);const app express(); app.get(/request, (req, res, next) > {//send 响应内容的累心//http 状态码req.name 张三;next(); }) app.get(/request, (req, res) > {//send 响应内容的累心//http 状态码res.send(req.name); }) app.liste…

python choose语句作用_理解闭包是如何与变量作用域相互影响的

原文标题&#xff1a;KNOW HOW CLOSURES INTERACT WITH VARIABLE SCOPE比如说你现在想要对一组数字进行排序&#xff0c;同时希望提高一组数字的优先级使这组数字优先显示。这种模式在展示用户接口时非常有用&#xff0c;在展示用户接口时经常需要优先展示一些重要信息以及异常…

前端学习(1368):app.use使用

const express require(express);const app express(); app.use((req, res, next) > {console.log(请求走了use中间件);next(); }) app.use(/request, (req, res, next) > {console.log(请求走了use中间件/hh)next() }) app.get(/list, (req, res) > {//send 响应内…

JDE Client开发端 左侧边栏设置

转载于:https://www.cnblogs.com/GYoungBean/p/4299317.html

cmd oracle 连接实例_C#连接Oracle数据库的实例方法

1.建立连接字符串&#xff0c;里面包含数据库名称、用户名和密码2.建立操作字符串&#xff0c;里面是对数据操作的SQL语句3.建立Connection&#xff0c;用连接字符串作为参数建立4.建立Command&#xff0c;用操作字符串和Connection作为参数5.建立DataAdapter&#xff0c;用Com…

59-混沌操作法感悟2.(2015.2.25)

混沌操作法感悟2羊年到了&#xff0c;今年要好好努力&#xff0c;争取赚到满意的收入。今天刚来到上海&#xff0c;明天开始上班&#xff0c;今天更新下春节期间在家的思考。随机性被视为噪音是因为时间因素&#xff0c;时间框架的长短性。如果以小时为时间框架&#xff0c;这种…