在文件夹image中有index.html文件,它的内容如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="http://127.0.0.1:3000/Resources" method="POST" enctype="multipart/form-data">
<p>
姓名:<input type="text" name = "name"/>
</p>
<p>
年龄:<input type="text" name = "age"/>
</p>
<p>
性别: <input type="radio" name = "sex" value="男"/>男
<input type="radio" name = "sex" value="女"/>女
</p>
<p>
图片:<input type="file" name = "图片"/>
</p>
<p>
<input type="submit"/>
</p>
</form>
</body>
</html>
在Express框架中,代码如下:
var express = require("express");
var app = express();
app.use(express.static("./image"));
app.listen(3000);
前端输入网址:
http://127.0.0.1:3000/
后端读取image文件夹下的index.html文件,呈现在前端,执行结果如下:
|