Auto commit

上级 ca207a2f
console.log("欢迎来到 InsCode");
\ No newline at end of file
console.log("欢迎来到 InsCode");
//需要安装express
//启动后app.js,再使用请求html的接口
const express=require('express')
//创建一个网站app,网站可以存放多个网页
const app=express()
//批量批量执行
for(let i=0;i<100;i++){
//创建网页:app.listen对应的端口网站:一个端口可以有多个网页:write是直接编辑网页
app.get('/page'+i,(req,resp)=>{
resp.setHeader('Content-Type', 'text/html;charset=UTF-8') //解决启动网站后网页显示中文乱码的问题
//写网页内容:读取数据库输出数据
//action = "http://localhost:5000/" //后端接收数据的端口
//method = "POST" //method的post方法提交请求至后端,供后台接收:估计经过后端处理后,可以将数据发回至前端,可能是
//多按行时,要注意标签空格,否则不是html标签,是字符串
let myhtml=
`<form
action = "http://localhost:5000/post"
method = "post"
encType = "multipart/form-data" >
<input multiple type ="file" name ="文件" >
账号:<input type="text" placeholder="请输入账号" name="账号z">
密码:<input type="password" placeholder="请输入密码" name="password">
<input type = "submit" value = "提交后台" >'
</form>`
resp.write('<h1>js创建网页成功:这是网页'+ i +'</h1>')
resp.write(myhtml)
resp.end()
})
}
//启动网站服务器:使这些网页可以访问:这里的端口是访问网页的端口,并非后端接收数据的端口:
app.listen(8000,()=>{
console.log("server is statr 服务启动")
})
//采用 POST 方法,浏览器将会按照下面两步来发送数据。首先,浏览器将与 action 属性中指定的表单处理服务器建立联系,一旦建立连接之后,浏览器就会按分段传输的方法将数据发送给服务器
\ No newline at end of file
......@@ -4,15 +4,15 @@
"description": "",
"main": "index.js",
"scripts": {
"dev": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
"dev": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/node": "^18.0.6",
"node-fetch": "^3.2.6"
"@types/node": "^18.0.6",
"express": "^4.18.2",
"node-fetch": "^3.2.6"
}
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册